handleSIGCLD: Establish or remove a dummy handler for SIGCLD signals

Description Usage Details Value Note Author(s) References See Also Examples

Description

Establish handleSIGCLD or remove ignoreSIGCLD a dummy handler for SIGCLD signals

Usage

1
2

Details

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.

Value

No return value.

Note

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.

Author(s)

Gregory R. Warnes greg@warnes.net, with financial support from Metrum Research Group, LLC http://www.metrumrg.com.

References

W.R. Stevens and S.A. Rago, Advanced Programming in the UNIX environment, 2nd ed. (c) 2005, Pearson Education, pp 308-310.

See Also

fork, wait, signal

Examples

 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()

warnes/fork documentation built on May 4, 2019, 12:59 a.m.