From: Stephen L Johnson Date: Wed, 27 Sep 2000 03:35:45 +0000 (+0000) Subject: moved ALRM handler into eval. close FIFO outside of eval to prevent orphan X-Git-Tag: spong-2_7_0-beta1~22 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74013c3a2c8b12668474ade63ad3727539294fa3;p=spong.git moved ALRM handler into eval. close FIFO outside of eval to prevent orphan --- diff --git a/src/lib/Spong/Network/plugins/check_ping b/src/lib/Spong/Network/plugins/check_ping index be71857..304b3c7 100755 --- a/src/lib/Spong/Network/plugins/check_ping +++ b/src/lib/Spong/Network/plugins/check_ping @@ -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( ) { - $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( ) { + $message .= $_; + if( /bytes from/ ) { $pingok = 1; } + if( /is alive/ ) { $pingok = 1; } + } + + alarm(0); + close PING; + }; if( ! $pingok ) { $color = "red";