http://qs321.pair.com?node_id=700927


in reply to Re^2: print on reboot or process shutdown
in thread print on reboot or process shutdown

You can use a signal handler to cacth SIGTERM

$SIG{TERM}=sub { #do something here };

But that cannot trap a SIGKILL so if you or your system make a kill -9, it will not be intercepted. And, no, AFAIK there is no way to intercept a SIGKILL because it should be the last resort to kill a not responding process.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."