[Info-vax] Check if a process will auto-terminate

AEF spamsink2001 at yahoo.com
Thu Apr 30 09:39:38 EDT 2009


On Apr 28, 7:23 am, "Stephen Davies" <no... at nowhere.com> 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.
>
> Thanks in advance,
>
> Steve D.

Steve,

Does this do what you need?

$ TYPE CMD*.COM

DISK$DATA1:[FELDMAN.VMS.DCL.SPAWN]CMD.COM;1

$ SPAWN/NOWAIT @CMD_SUB.COM
$_WAIT:
$ WAIT 0:00:01
$ NUMSUB = F$GETJPI("","PRCCNT")
$ IF (NUMSUB.GT.0) THEN GOTO _WAIT

DISK$DATA1:[FELDMAN.VMS.DCL.SPAWN]CMD_SUB.COM;1

$ N = 0
$ AGAIN: show time
$ wait 0:00:01
$ N = N + 1
$ IF (N.LT.3) THEN goto AGAIN
$ EXIT
$
$ SPAWN @CMD
%DCL-S-SPAWNED, process FELDMAN_1 spawned
%DCL-S-ATTACHED, terminal now attached to process FELDMAN_1
%DCL-S-SPAWNED, process FELDMAN_2 spawned
  30-APR-2009 13:27:15
  30-APR-2009 13:27:16
  30-APR-2009 13:27:17
%DCL-S-RETURNED, control returned to process FELDMAN
$
$ SPAWN
%DCL-S-SPAWNED, process FELDMAN_1 spawned
%DCL-S-ATTACHED, terminal now attached to process FELDMAN_1
$ @CMD
%DCL-S-SPAWNED, process FELDMAN_2 spawned
  30-APR-2009 13:27:25
  30-APR-2009 13:27:26
  30-APR-2009 13:27:27
$
$ SHOW PROC

30-APR-2009 13:27:43.54   User: FELDMAN          Process ID:
00016FAC
                          Node: NOT_ME            Process name:
"FELDMAN_1"

Terminal:
User Identifier:    [FELDMAN]
Base priority:      4
Default file spec:  DISK$DATA1:[FELDMAN.VMS.DCL.SPAWN]
$



More information about the Info-vax mailing list