Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Re: Re: Gracefully exiting daemons

by Brovnik (Hermit)
on Jun 26, 2001 at 02:32 UTC ( #91469=note: print w/ replies, xml ) Need Help??

in reply to Re: Re: Gracefully exiting daemons
in thread Gracefully exiting daemons

You can of course catch the signal and do nothing, or (as here) just set a variable for you to look at later.

$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++; }
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.

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".

Comment on Re: Re: Re: Gracefully exiting daemons
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://91469]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2015-03-01 05:47 GMT
Find Nodes?
    Voting Booth?

    On my keyboard, Caps lock is:

    Results (466 votes), past polls