Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Implicit killing of subprocesses
On Aug 28, 2:47pm, Peter Stephenson wrote:
}
} In this case, the NOHUP option is irrelevant --- because you don't have
} job control (it's determined by the MONITOR option which is unset in
} non-interactive shells), the shell doesn't send SIGHUP to processes on
} exiting (without job control it doesn't have much idea of which
} processes would need it). So I think you get the effect you want.
I think the effect Rene wants is that the coproc job DOES get killed when
the script exits? Which won't happen with MONITOR turned off.
A coproc is not very different than a backgroup job started with "... &"
except for where its standard input and output are connected.
However, you can "setopt monitor" in the script. If you do this before
starting the coproc, zsh SIGHUPs the job before exiting. You get the
usual warnings:
coprocscript:7: you have running jobs.
coprocscript:7: warning: 1 jobs SIGHUPed
If the setopt comes after the coproc, the first warning is printed, but
the SIGUP is not sent.
If the job started with coproc can be relied upon to exit when it gets
EOF on its standard input, then instead of setopt monitor you can end it
explicitly with:
TRAPEXIT() { coproc exit }
The "coproc exit" is not magic, it's just an idiom for closing all the
existing coproc descriptors in the parent shell by starting a new no-op
coproc in place of whichever one is already running. It is best if the
TRAPEXIT is not created until after the coproc job is started.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author