in reply to Re: Re: Gracefully exiting daemons
in thread Gracefully exiting daemons
You should of course think carefully about ignoring signals, expecially INT and TERM, since if you get these, someone/something is trying to tell you something.$SIG{HUP} = \&catch; my $caught = 0; my $count = 0; print "I am $$, HUP me\n"; for (0..10) { sleep (5); # pretending to do stuff print "$_\n"; } die "I was HUPed $caught times" if $caught; ### Subroutines below sub catch { $caught++; }
But, delaying handling e.g. HUP or USR1 until it is a better time to handle is OK.
Make sure you document the signal handling well, specially
if it is not expected behaviour. E.g. HUP is often used to mean
"Please reread your config file".
--
Brovnik
|
|---|