Penguin

Differences between version 2 and previous revision of SIGCHLD.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Tuesday, May 4, 2004 1:43:13 pm by JohnMcPherson Revert
Older page: version 1 Last edited on Tuesday, November 18, 2003 4:09:11 pm by JohnMcPherson Revert
@@ -1,9 +1,12 @@
 !!!Signal: Child process 
  
-Child process has changed state. This signal is raised whenever a child process recieves a signal or terminates. This can be used to call wait4(2) to cleanup any ZombieProcess''''es that the process may have. On some Unix's it is possible to explicitly set SIGCHLD to "SIG_IGN" (ignore) and child processes will be cleaned up automatically. The default action (SIG_DFL) for this signal is to ignore it (but this does not reap the process until the parent wait()s). 
+Child process has changed state. This signal is raised whenever a child process recieves a signal or terminates. This can be used to call wait4(2) to cleanup any ZombieProcess''''es that the process may have. On some Unixes it is possible to explicitly set SIGCHLD to "SIG_IGN" (ignore) and child processes will be cleaned up automatically. The default action (SIG_DFL) for this signal is to ignore it (but this does not reap the process until the parent wait()s). 
  
-In perl, would do one of the following: 
+From the signal(2) manpage:  
+;:According to POSIX (B.3.3.1.3) you must not set the action for SIGCHLD to SIG_IGN. Here the BSD and SYSV behaviours differ, causing BSD software that sets the action for SIGCHLD to SIG_IGN to fail on Linux.  
+  
+ In perl, you would do one of the following: 
  
 1. wait till child finishes 
  
 ---- 
@@ -14,9 +17,11 @@
 
  
  # if fork returned -1, there was an error forking (but we'll ignore that) 
  # if here, assume it is the parent processes 
+ # wait() call won't return until the child process has finished.  
  wait(); # when this returns, the child has been "reaped" 
+ # could use waitpid() with WNOHANG to return -1 if child isn't finished yet  
  # when here, the child process has finished. 
  ... 
 ----