next unless ($time > $forker_timeout);
### TODO: use &time2string()?
- &WARN("Fork: looks like we lost '$_', executed $time ago.");
- delete $forked{$_};
+ &WARN("Fork: looks like we lost '$_', executed $time ago");
+
+ if ( -d "/proc/$forked{$name}{PID}") {
+ my $pid = $forked{$name}{PID};
+ &status("Fork: killing $name ($pid)");
+ kill 9, $pid;
+ }
+
+ delete $forked{$name};
}
my $count = 0;
$continue++ if ($forked{$name}{PID} == $$);
if ($continue) {
- &DEBUG("hrm.. fork pid == mypid == $$; how did this happen?");
+ &WARN("hrm.. fork pid == mypid == $$; how did this happen?");
+
} elsif ( -d "/proc/$forked{$name}{PID}") {
&status("fork: still running; good. BAIL OUT.");
return 0;
+
} else {
&WARN("Found dead fork; removing and resetting.");
$continue = 1;
if ($continue) {
# NOTHING.
+
} elsif (time() - $time > 900) { # stale fork > 15m.
&status("forked: forked{$name} presumably exited without notifying us.");
+
} else { # fresh fork.
&msg($who, "$name is already running ". &Time2String(time() - $time));
return 0;