Subscribe Bookmark RSS Feed

Kill RunProgram()

msharp

Super User

Joined:

Jul 28, 2015

Is there a way to kill the RunProgram() call?  I have a JSL script that uses RunProgram to make a data query.  Sometimes the data query can get hung up on something on the server end (usually if I mistakenly make too big a query).  I'd like to implement a timer that will kill the RunProgram if it's been running too long.  Any thoughts?

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

On Windows, this works to kill a 500 second program after just 10 seconds:

RP = RunProgram(

  Executable(

  "PING.EXE"

  ),

  Options( {"-n 500", "localhost"} ),

  ReadFunction(

  Function( {this},

  Write( this << read )

  )

  )

);

x = schedule(10, RP=0;)

On MAC JMP 11 something similar will work.  MAC JMP 12  RunProgram does not break the connection correctly, but that is fixed for a future release.


The RP variable is a handle to the run program object.  When you destroy the last handle to the object by setting the RP variable to a different value, the run program object closes the stdin/stdout handles to the external program.  You'll get a log message about it.


There is no way to do this if you are using readfunction("text").


The database server should see this like any other broken connection and release resources appropriately.

Craige
2 REPLIES
Solution

On Windows, this works to kill a 500 second program after just 10 seconds:

RP = RunProgram(

  Executable(

  "PING.EXE"

  ),

  Options( {"-n 500", "localhost"} ),

  ReadFunction(

  Function( {this},

  Write( this << read )

  )

  )

);

x = schedule(10, RP=0;)

On MAC JMP 11 something similar will work.  MAC JMP 12  RunProgram does not break the connection correctly, but that is fixed for a future release.


The RP variable is a handle to the run program object.  When you destroy the last handle to the object by setting the RP variable to a different value, the run program object closes the stdin/stdout handles to the external program.  You'll get a log message about it.


There is no way to do this if you are using readfunction("text").


The database server should see this like any other broken connection and release resources appropriately.

Craige
msharp

Super User

Joined:

Jul 28, 2015

Thank you.