From 74013c3a2c8b12668474ade63ad3727539294fa3 Mon Sep 17 00:00:00 2001 From: Stephen L Johnson Date: Wed, 27 Sep 2000 03:35:45 +0000 Subject: [PATCH] moved ALRM handler into eval. close FIFO outside of eval to prevent orphan --- src/lib/Spong/Network/plugins/check_ping | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) 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"; -- 2.30.2