You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/09/04 05:12:06 UTC
svn commit: rev 43314 - spamassassin/trunk/spamd
Author: felicity
Date: Fri Sep 3 20:12:06 2004
New Revision: 43314
Modified:
spamassassin/trunk/spamd/spamd.raw
Log:
bug 3743: have the child reaper deal with multiple children if necessary, also have the restart handler wait for the specific pid to exit instead of any generic pid.
Modified: spamassassin/trunk/spamd/spamd.raw
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Fri Sep 3 20:12:06 2004
@@ -1764,13 +1764,22 @@
# takes care of dead children
sub child_handler {
my ($sig) = @_;
- $SIG{CHLD} = \&child_handler; # reset as necessary
- my $pid = wait; # reap the child
- delete $children{$pid}; # remove the child out of the pool
unless ($main::INHIBIT_LOGGING_IN_SIGCHLD_HANDLER) {
- logmsg("server hit by SIG$sig, pid $pid");
+ logmsg("server hit by SIG$sig");
}
+
+ # clean up any children which have exited
+ while((my $pid = waitpid(-1, WNOHANG)) > 0) {
+ # remove them from our child listing
+ delete $children{$pid};
+
+ unless ($main::INHIBIT_LOGGING_IN_SIGCHLD_HANDLER) {
+ logmsg("handled cleanup of child pid $pid");
+ }
+ }
+
+ $SIG{CHLD} = \&child_handler; # reset as necessary, should be at end
}
sub restart_handler {
@@ -1780,7 +1789,7 @@
$SIG{CHLD} = 'DEFAULT'; # we're going to kill our children
foreach (keys %children) {
kill 'INT' => $_;
- my $pid = wait;
+ my $pid = waitpid($_, 0);
logmsg("child $pid killed successfully");
}
%children = ();