| handleSIGCLD {fork} | R Documentation |
Establish handleSIGCLD or remove ignoreSIGCLD a dummy
handler for SIGCLD signals
handleSIGCLD() restoreSIGCLD()
The handleSIGCLD function establishes a 'dummy' handler for
SIGCLD signals. It accepts signals from exiting child processes
created by fork and ignores them. This prevents child
processes from becoming 'zombies', which would occurs when the parent
process does not handle this signal.
The restoreSIGCLD function restores the previous (lack of)
signal handler.
No return value.
The SIGCLD handling mechanism implemented by handleSIGCLD
should prevent zombie process creation on systems derived from both
SYSV and BSD UNIX, including Linux, Mac OSX, NetBSD, and Solaris.
Gregory R. Warnes greg@random-technologies-llc.com, with financial support from Metrum Research Group, LLC http://www.metrumrg.com.
W.R. Stevens and S.A. Rago, Advanced Programming in the UNIX environment, 2nd ed. (c) 2005, Pearson Education, pp 308-310.
## set up the dummy signal hander
handleSIGCLD()
## Generate 100 child processes
for(i in 1:100)
{
pid = fork(slave=NULL)
if(pid==0)
{
## don't do anything useful
exit()
}
}
## remove the dummy signal handler
restoreSIGCLD()