in reply to forking subroutines?
use POSIX ":sys_wait_h"; sub REAPER { my $child; while ($child = waitpid(-1,WNOHANG)) { $Kid_Status{$child} = $?; } $SIG{CHLD} = \&REAPER; # still loathe sysV } $SIG{CHLD} = \&REAPER; .............. for (1..6) { do { $pid = fork(); unless (defined $pid) { warn "cannot fork: $!"; sleep 10; } } until defined $pid; if ($pid) { # parent print "forked process $pid\n"; } else { # child my_sub(@parms); exit; # don't forget this } }
Untested. Have fun.
|
---|