[SunHELP] for loop changes nohup?
velociraptor at gmail.com
Mon Nov 22 07:54:00 CST 2004
On Mon, 22 Nov 2004 10:33:14 +0000, Richard Russell
<richard.russell at db.com> wrote:
> Thanks -- my immediate thought on this is that it could explain the
> opposite behaviour more likely than what I actually see...
> ie you're suggesting this:
> ./start: ...
> ksh --> sh --> nohup --> ksh --> nohup & --> java
> for i in one; do ./start; done ...
> ksh ( --> ksh subshell ) --> sh --> nohup --> ksh --> nohup & --> java
> Why would exiting the ksh from the for loop example be more likely to
> cause the java process to exit than it would in the first example?
> Certainly, I would have expected that the nohup would catch the signals
> anyway, so a change at this point shouldn't affect the java process, but
> why would adding a subshell affect it?
> Then again, I've never really understood how signals propagate...
> Does anyone have any other ideas?
I think what Sheldon was implying that if the for loop is run in a subshell,
any process spawned by that subshell will die when the parent pid dies.
So, when the for loop exits, it's child processes die as well. The question
is, what signal does the shell send with it exits?
According to the man page, nohup only causes processes to ignore
SIGHUP and SIGQUIT. If you background the process it also ignores
interrupts. It doesn't prevent a SIGTERM from working.
I'd think you could test this by:
log in from a second terminal
from within the first login shell:
run another shell process
then start your nohup script
in the second terminal:
do a ptree on the script
kill the pid of the login shell of your initial terminal session
But that still doesn't really test what signal is sent by a script's subshell
exiting; I think you'll have to read up on ksh/sh.
What's the standard method for starting a process without it being a
child of the current process? Can you even do it from within a shell
More information about the SunHELP