Commit e46a69ed authored by Robert Ricci's avatar Robert Ricci

Fix a bug in which we could call alarm() with a zero or negative

value under some circumstances, which would result in not actually
timing out children that were taking too long.
parent 101be37f
......@@ -376,14 +376,26 @@ while (1) {
"Uh oh, I have no children left, something is wrong!\n";
}
#
# If the oldest has already expried, just kill it off right now, and go
# back around the loop
#
my $now = time();
my $waittime = ($oldest + 120) - time();
#
# Kill of the oldest if he gets too old while we're waiting
#
local $SIG{ALRM} = sub { kill("TERM", $oldestpid); };
alarm(($oldest + 120) - time());
if ($waittime <= 0) {
kill("TERM",$oldestpid);
} else {
alarm($waittime);
}
my $childpid = wait();
my $exitstatus = $?;
alarm 0;
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment