commit:98307380429da3ad6e18c99200da6449719dc106
author:Chip Black
committer:Chip Black
date:Mon Aug 18 02:31:17 2008 -0500
parents:cf07941ce4d3f44228cbc776e0c1190b2af9dc92
Added hung check handling
diff --git a/runcheckdir b/runcheckdir
line changes: +15/-2
index 6b5bcca..d6589f2
--- 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 = <CHECK>;
 $details = join('', <CHECK>);
 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}};