[Resmon-devel] [resmon commit] r158 - trunk

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Mon Mar 9 17:39:53 EDT 2009


Author: mark
Date: 2009-03-09 17:39:53 -0400 (Mon, 09 Mar 2009)
New Revision: 158

Modified:
   trunk/resmon
Log:
Change the zombie reaping process so we can still get return values ($?)
from system/backtick commands

Modified: trunk/resmon
===================================================================
--- trunk/resmon	2009-01-26 18:09:22 UTC (rev 157)
+++ trunk/resmon	2009-03-09 21:39:53 UTC (rev 158)
@@ -8,7 +8,7 @@
 
 use strict;
 use Time::HiRes qw( gettimeofday tv_interval sleep );
-use POSIX qw( setsid );
+use POSIX qw( setsid sys_wait_h );
 use Getopt::Long;
 use Data::Dumper;
 use vars qw($config_file $debug $status_file $interface $port $config
@@ -98,6 +98,13 @@
   $rmlast = [gettimeofday];
 }
 
+sub reap_zombies {
+    my $kid;
+    do {
+        $kid = waitpid(-1, WNOHANG);
+    } while $kid > 0;
+}
+
 unless($debug) {
   fork && exit;
   setsid;
@@ -127,7 +134,6 @@
       if (!$check_rv) {
         eval {
           local $SIG{ALRM} = sub { die "alarm\n" };
-          local $SIG{CHLD} = 'IGNORE';
           alarm $config->{timeout};
           if($coderef) {
             ($check_rv, $check_mess) = $coderef->($monobj);
@@ -167,7 +173,9 @@
     $sighup = 0;
     reconfigure();
   } else {
+    reap_zombies();
     wait_interval();
+    reap_zombies();
   }
   die "Exiting.\n" if($sigint);
   print "\n---- ".localtime(time)."----------\n"



More information about the Resmon-devel mailing list