]> git.etc.gen.nz Git - spong.git/commitdiff
moved ALRM handler into eval. close FIFO outside of eval to prevent orphan
authorStephen L Johnson <sjohnson@monsters.org>
Wed, 27 Sep 2000 03:35:45 +0000 (03:35 +0000)
committerStephen L Johnson <sjohnson@monsters.org>
Wed, 27 Sep 2000 03:35:45 +0000 (03:35 +0000)
src/lib/Spong/Network/plugins/check_ping

index be7185780cb3780d672cb292738c687b7ac6a002..304b3c7b48a11fba3ff98328a03b8a8cd820eb3f 100755 (executable)
@@ -29,19 +29,20 @@ sub check_ping {
         my $pingok = 0;
         $myping =~ s/HOST/$host/g;
 
-        $SIG{'ALRM'} = sub { die };
-        alarm(5);
-
-        eval <<'_EOM_';
-        open( PING, "$myping 2>&1 |") || warn "can't call ping: $!";
-        while( <PING> ) { 
-           $message .= $_; 
-           if( /bytes from/ ) { $pingok = 1; }
-            if( /is alive/ )   { $pingok = 1; }
-        }
-_EOM_
-        alarm(0);
-        close PING;
+        eval {
+           local $SIG{'ALRM'} = sub { die };
+           alarm(5);
+
+           open( PING, "$myping 2>&1 |") || warn "can't call ping: $!";
+           while( <PING> ) { 
+              $message .= $_; 
+              if( /bytes from/ ) { $pingok = 1; }
+               if( /is alive/ )   { $pingok = 1; }
+           }
+
+           alarm(0);
+           close PING;
+        };
 
         if( ! $pingok ) { 
            $color = "red";