From: Bill Erickson Date: Fri, 27 Feb 2015 16:00:12 +0000 (-0800) Subject: JBAS-479 clean up forked children in throttle_disbatcher.pl X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3c9864f97c9b614c6002a9d7128fcff9b39cf98d;p=working%2FEvergreen.git JBAS-479 clean up forked children in throttle_disbatcher.pl When registering a sig handler for CHLD, we have to waitpid for child procs to clean them up or defunct procs will proliferate. Also update counts with each reaped child, since that's the only accurate way to know how many children have completed their tasks. See http://perldoc.perl.org/perlipc.html#Signals SIGCHLD Signed-off-by: Bill Erickson --- diff --git a/KCLS/linking/throttle_disbatcher.pl b/KCLS/linking/throttle_disbatcher.pl index 13e6a380b4..12bee51540 100755 --- a/KCLS/linking/throttle_disbatcher.pl +++ b/KCLS/linking/throttle_disbatcher.pl @@ -28,6 +28,7 @@ use Getopt::Long; use Time::localtime; +use POSIX qw/:sys_wait_h/; $SIG{CHLD} = \&sig_handler; @@ -152,8 +153,12 @@ sub dispatch { } sub sig_handler { - $running--; - $count++; + # clean up child processes + while ((my $child = waitpid(-1, WNOHANG)) > 0) { + print "reaping child $child\n"; + $running--; + $count++; + } } __END__