Subject: | Set $SIG{INT} and $SIG{TERM} so myapp.pid get deleted after ./myapp_script.pl stop |
Perhaps i miss a thing, but after ./MyApp.pl stop the pidfile will not
deleted?!?!
So i installed INT and TERM ...
i think it could be a good idea to check the ref of the old $SIG and
then make a callback, calling the old coderef, after deleting the pidfile?
my $old_sigdie = $SIG{__DIE__};
$SIG{__DIE__} = sub {
# after your work
$SIG{__DIE__} = $old_sigdie;
die(@_);
};
i dont know, is this possible? What is with a local $SIG{__DIE__} only
while starting daemonize? :-/ so this will make the local keeping alive
i think. So this is not as good as i think befor.
Subject: | Daemon.pm.patch |
--- Daemon.pm.orig 2009-03-24 12:09:39.000000000 +0100
+++ Daemon.pm 2009-03-24 13:06:37.000000000 +0100
@@ -144,6 +146,10 @@
}
};
+ $SIG{INT} = $SIG{TERM} = sub {
+ unlink $pidfile or warn "Cannot remove $pidfile";
+ };
+
INFO "Process ID is $$";
pid_file_write($$);
INFO "Written to $pidfile";