Question
· Aug 28

JOB $SYSTEM.obj

IS THERE A WAY TO JOB A $SYSTEM.OBJ FUNCTION AND FIND IF THE JOB IS RUNNING OR FINISHED TO ASYNCHRONOUSLY CONTINUE OR HALT THE PROCESS?

Discussion (5)2
Log in or sign up to continue

Just create a "job wrapper" around the function, then JOB the subroutine:

JOBEXPORT ; SET UP A ROUTINE TO EXPORT A FILE.
 Q ; USE SEPARATE ENTRY POINT, JUST IN CASE...
 ;
SAVE ; HERE'S THE ACTUAL SUBROUTINE TO EXPORT THE ROUTINE.
 ; IT THROWS AWAY ANY I/O, MAYBE YOU DON'T WANT THAT.
 D $SYSTEM.OBJ.Export("RTOSAVE.INT","E:\Z\SAVEDROUTINE.RTN")
 Q
 

Then, just JOB the subroutine and get the job number:

JOB SAVE^JOBEXPORT SET CHLD=$ZCHILD WRITE CHLD,!

( This prints the child process ID, if you don't need to see it you can omit the last WRITE statement. )

Later, to see if the routine is still working, use the $DATA and $^JOB functions:

WRITE $DATA(^$JOB(CHLD))

If the 0 the job has completed (or possibly crashed, I suppose) - if it's 1 then the task is still running. There are utilities both in the Management Portal and in the %SYS namespace to terminate rogue processes.

Hope this helps!

[[ Edited for minor error in code... there might be more. ]]