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

Joseph Huber joseph.huber at NIRWANA.web.de
Tue Apr 28 14:06:57 EDT 2009


sapienzaf schrieb:
> On Apr 28, 1:21 pm, Joseph Huber <joseph.hu... at NIRWANA.web.de> wrote:
>> Of course it does, the second @CMD executes in the master process, the
>> first one is a subprocess of a different master process.
> 
> No, it doesn't.  You're not understanding the original question.
> 
> In an interactive session, if you type $SPAWN on a command line all by
> itself then the next line of input is handled by the spawned sub-
> process.
> 
> Thus, in:
> 
> $ spawn
> $ @cmd
> $ ...        <other commands executed in the sub-process>
> $ logout  <returns control to the parent>
> 
> The @CMD is processed in the context of the sub-process and it will
> have the master pid of its parent.  The parent is hibernating, waiting
> for the sub-process to complete.  When the @CMD completes control
> stays in the sub-process.
> 
> In:
> 
> $ spawn @cmd
> 
> The execution environment is the same.  That is, the @CMD is executed
> in the sub-process and it has a hibernating parent.  However, as soon
> as the @CMD completes control is returned to the parent.

No, the subprocess does NOT know if the parent is hibernating, i.e. it 
cannot differentiate between the invocation method SPAWN or 
SPAWN/NOWAIT, but it knows it is in a subprocess by comparing PID and 
MASTER_PID.
A "@CMD" by itself does not create a new subproces, so it does not 
"return" to a parent at EXIT or EOF.

> The original question was how to differentiate those two cases.  From
> within the CMD procedure, how can it determine whether control will
> return to the parent once it completes, or whether control will remain
> in the subprocess.
> 
> I'm not sure it can be done.
True it can't differentiate the two cases,
but I see only a need to know if it can do a "SPAWN @CMD" or a 
"SPAWN/NOWAIT @CMD", because the /NOWAIT case will loose its parent 
before @CMD finishes.


-- 

  Joseph Huber   - http://www.huber-joseph.de



More information about the Info-vax mailing list