in reply to Best way to kill a child process
Anyway, the following line of code installs a signal handler for the CHLD signal. When that signal happens, the while loop runs which will read and discard the status of any children who have died (in general case might be more than one). It is ok to put this at the beginning of the code (which means that the child will get one of these too) - but it won't be getting CHLD signals itself.
$SIG{CHLD} = sub {while (waitpid(-1, WNOHANG) > 0){} };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to kill a child process
by Eliya (Vicar) on Sep 21, 2011 at 13:58 UTC | |
by Marshall (Canon) on Sep 21, 2011 at 15:31 UTC | |
by Eliya (Vicar) on Sep 21, 2011 at 18:41 UTC | |
by Marshall (Canon) on Sep 22, 2011 at 00:50 UTC | |
by flexvault (Monsignor) on Oct 10, 2011 at 15:16 UTC | |
|