Skip to content

Instantly share code, notes, and snippets.

@cornet
Created October 20, 2010 18:16
Show Gist options
  • Save cornet/636987 to your computer and use it in GitHub Desktop.
Save cornet/636987 to your computer and use it in GitHub Desktop.
sub sig_child_handler {
while ( ( $SIGCHLD_PID = waitpid( -1, WNOHANG ) ) > 0 ) {
E3::dbprint("caught $SIGCHLD_PID\n" ) if $E3::DEBUG;
if (exists $childPID{$SIGCHLD_PID}) {
delete $childPID{$SIGCHLD_PID};
if ($children_spawned > 0) {
E3::dbprint("decrement children_spawned counter\n" ) if $E3::DEBUG;
}
} else {
E3::dbprint("not our child\n" ) if $E3::DEBUG;
}
}
$children_spawned = scalar(keys(%childPID));
$SIG{CHLD} = \&sig_child_handler;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment