Description Usage Details Value Note Author(s) References See Also Examples
Establish handleSIGCLD
or remove ignoreSIGCLD
a dummy
handler for SIGCLD signals
1 2 |
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@warnes.net, 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## 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()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.