Question
· Jun 15, 2018

Kill process started by JOB

Can anybody give me a correct example to kill process started by JOB command?

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

When you need to switch namespaces, instead of saving the current namespace and then restoring it after, you can put the code into its own method or routine and use NEW $NAMESPACE, for example:

Method KillJob(job) {
new $namespace
s $namespace="%SYS"
do whatever(job)
}

and the original namespace will be restored when the method exits. I think this also works inside of an old-fashioned argumentless DO block.

Ruslan,

After execution, the JOB Command sets system variable $ZCHILD

$ZCHILD contains the ID of the last child process that the current process created with the JOB command. If your process has not used JOB to create a child process, $ZCHILD returns 0 (zero).

$ZCHILD being set does not mean that the job was successfully started. It only means that the process was created and the parameters were passed successfully.

Now you have the OIID in hands to apply to $System.Process.Terminate(bgjob) as suggested already by  Vitaliy Serdtsev