foreach my $node (@nodes) {
print "$node ";
chomp $node;
wait_for_a_kid() if keys %pid_to_node > 8;
$pid = fork;
if ($pid) {
## parent does...
$pid_to_node{$pid} = $node;
}
else {
local $SIG {ALRM} = sub {
kill -15, $$ or die "kill: $!";
print "\tKilled PID $$\n"}; # Just SIGTERM.
eval {
## child does...
setpgrp(0,0);
print $$."\n";
exit !&GetSvrStatus($node);
alarm 5;
waitpid $pid => 0;
};
}
}
## final reap:
1 while wait_for_a_kid();
In reply to Re^4: forking and timeouts
by Earindil
in thread forking and timeouts
by Earindil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |