Handle expected signals in tsiggss authsock.pl script

When the authsock.pl 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.
This commit is contained in:
Mark Andrews
2021-01-20 13:53:50 +11:00
committed by Ondřej Surý
parent f8c6872beb
commit 216a97188d

View File

@@ -42,6 +42,11 @@ open(my $pid,">",$pidfile)
print $pid "$$\n";
close($pid);
# close gracefully
sub rmpid { unlink "$pidfile"; exit 1; };
$SIG{INT} = \&rmpid;
$SIG{TERM} = \&rmpid;
if ($timeout != 0) {
# die after the given timeout
alarm($timeout);