Commit 469bfac7 authored by Leigh Stoller's avatar Leigh Stoller

Fix up exit handling, was failing to kill children.

parent 4cead7b8
......@@ -88,6 +88,17 @@ if (! $debug) {
}
}
#
# Setup a signal handler to kill children and exit.
#
sub handler()
{
print "Caught a TERM. Killing children and exiting\n";
Cleanup();
exit(0);
}
$SIG{TERM} = \&handler;
#
# Delay at startup to allow ops time to boot. Hopefully this
# will prevent too many false alarms at system startup time.
......@@ -97,16 +108,6 @@ sleep(60)
my ($opswatcher,$bosswatcher,$psdwatcher,$deadpid);
#
# Setup a signal handler to kill children and exit.
#
sub handler()
{
fatal("Caught a TERM. Killing children and exiting\n")
if ($debug);
}
$SIG{TERM} = \&handler;
while (1) {
#
# We look for up to three different pubsubd daemons. One on ops, the
......@@ -258,18 +259,8 @@ sub notify($)
$TBOPS);
}
sub fatal($)
sub Cleanup()
{
my ($msg) = @_;
#
# Send a message to the testbed list.
#
SENDMAIL($TBOPS,
"Event watchdog daemon died",
$msg,
$TBOPS);
if (defined($opswatcher)) {
kill('TERM', $opswatcher);
}
......@@ -281,7 +272,22 @@ sub fatal($)
}
MarkDaemonStopped("event_watchdog")
if (!$debug);
}
sub fatal($)
{
my ($msg) = @_;
#
# Send a message to the testbed list.
#
SENDMAIL($TBOPS,
"Event watchdog daemon died",
$msg,
$TBOPS);
Cleanup();
die("*** $0:\n".
" $msg\n");
}
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