Commit 216a9718 authored by Mark Andrews's avatar Mark Andrews Committed by Ondřej Surý
Browse files

Handle expected signals in tsiggss script

When the script would be terminated with a signal,
it would leave the pidfile around.  This commit adds a signal
handler that cleanups the pidfile on signals that are expected.
parent f8c6872b
...@@ -42,6 +42,11 @@ open(my $pid,">",$pidfile) ...@@ -42,6 +42,11 @@ open(my $pid,">",$pidfile)
print $pid "$$\n"; print $pid "$$\n";
close($pid); close($pid);
# close gracefully
sub rmpid { unlink "$pidfile"; exit 1; };
$SIG{INT} = \&rmpid;
$SIG{TERM} = \&rmpid;
if ($timeout != 0) { if ($timeout != 0) {
# die after the given timeout # die after the given timeout
alarm($timeout); alarm($timeout);
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