From 98307380429da3ad6e18c99200da6449719dc106 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Mon, 18 Aug 2008 02:31:17 -0500 Subject: [PATCH] Added hung check handling --- runcheckdir | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/runcheckdir b/runcheckdir index 6b5bcca..d6589f2 100755 --- a/runcheckdir +++ b/runcheckdir @@ -80,11 +80,24 @@ if ($td < $every) { exit $oldstatus; } -open CHECK, '-|', $checkcommand; +my ($pid, $hung, $exitstatus); +$SIG{ALRM} = sub { + kill 9, $pid; + $hung = 1; +}; +alarm 10; + +$pid = open CHECK, '-|', $checkcommand; $status = ; $details = join('', ); close CHECK; -my $exitstatus = $? >> 8; +if ($hung) { + $status = 'TIMEOUT'; + $details = 'Check did not complete within ten seconds'; + $exitstatus = -1; +} else { + $exitstatus = $? >> 8; +} if ($exitstatus == 0 && $oldstatus != 0) { do_command($_) foreach @{$on{success}}; -- 2.25.1