in reply to Re: Re: Re: Re: (slightly OT) catching SIGTERM when system goes down
in thread (slightly OT) catching SIGTERM when system goes down

As a first step: daemonize your script and reboot the machine.

Always test under real-life conditions...

Concerning your question:
I don't know if any signal must be send in this case, googling didn't help and I'm to tired right now to dig further, sorry :(

FWIW: I experimented a little with this code

sub handler { my $sig = shift; `echo $sig >> ~/scratch/testsig`; exit if grep /$sig/, qw/INT TERM KILL CHLD ABRT HUP QUIT/; } $SIG{$_} = \&handler foreach keys %SIG; while(1){}

maybe that gets you started...but be carefull to have a console open to kill this from, just in case...

kind regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.

  • Comment on Re: Re: Re: Re: Re: (slightly OT) catching SIGTERM when system goes down
  • Download Code