This works fine. But lets say out of n children, m are sleeping waiting on network traffic from the server. The parent process sends USR1 signal to each one of those m children every 10 secs of uninterrupted sleep:sub cleanup { while ((my $kpid = waitpid(-1,WNOHANG)) > 0) { delete($kids{$kpid}); $kidcount--; } }
The signal handler is as follows:while ( $kidcount > 0) { my $secs = sleep 10; my $finishCount = $hostsfile->getCount - $kidcount; if ($secs == 10) { if ($outfile and $errfile) { print STDERR "Output is being logged into $outfile\n"; print STDERR "Errors are being logged into $errfile\n"; } print STDERR "\nFinished $finishCount hosts. following ($kidco +unt)hosts remaining:\n"; while ( my ($k, $v) = each %kids) { kill "USR1", $k; print STDERR "$v\n"; } print STDERR "\n"; } }
So upon 7 USR1 signals, the kid should exit out. This works perfectly fine with perl 5.8.4 running on a 64 bit linux(redhat 4) machine. But on a 32 bit linux(redhat 4) machine with perl 5.8.0 or a solaris 8 machine running the same perl this is what happens: The first time USR1 signal is received, the child executes the handler and everything is good. On the second time, the child just terminates. What am i doing wrong? I hope the code provided above and the explanation is clear. thanks in advance -yogisub killMyself { if ($waitcount > 6) { print STDERR "$serverName ERROR:: The host is hosed\n"; exit; } $waitcount++; }
In reply to signal handler question by yogi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |