[Info-vax] Check if a process will auto-terminate
Joseph Huber
joseph.huber at NOSPAM.web.de
Tue Apr 28 10:34:48 EDT 2009
Stephen Davies wrote:
> Hi,
>
> Please could someone tell me if there is a simple way that a command file
> can determine if it running in a process that will terminate as soon as
> the command file exits.
>
> eg, tell the difference between this:
> $ spawn @CMD
>
> and this:
> $ spawn
> $ @CMD
>
> The reason is that I have updated a command file to spawn a subprocess
> then exit but some legacy calls to the command file already spawn the
> command file, resulting in the sub-sub-process terminating almost
> immediately because its parent terminates.
>
> My current work-around is to use f$getjpi("", "LOGINTIM") and see if the
> process is less than a second old but I hope there's a better solution.
>
Uh no, I would check if the executing proc has a master process:
$ async = 0
$ if (f$mode() .eqs. "INTERACTIVE") .AND. F$GETDVI("SYS$OUTPUT","TRM")
$ then
$ x = f$getjpi("","PID")
$ y = f$getjpi("","MASTER_PID")
$! if we are in a subprocess, just run, else spawn/nowait
$ if x .eqs. y then async = 1
$ endif
$ if async
$ then
$ spawn/nowait @CMD
$ else
$ @CMD
$ endif
--
Joseph Huber, http://www.huber-joseph.de
More information about the Info-vax
mailing list