Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: (slightly OT) catching SIGTERM when system goes down

by robartes (Priest)
on Apr 09, 2003 at 14:12 UTC ( [id://249218]=note: print w/replies, xml ) Need Help??


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

At least on the RedHat machine I have here, processes are actually sent SIGTERM twice. Once from shutdown, and once from init. Init sends this signal to any process not belonging in the new runlevel it's switching to (in the case of a halt or reboot, 0 or 6 respectively), and your daemon should be included in this (if it's still in the original process group given to it's ancestor by init, or if it has become a child of init).

Here's the clincher however: 5 seconds after this SIGTERM, init follows this up with a SIGKILL, which is not trappable. In your script, as Tomte has suggested, the actual action to be taken upon receipt of the signal is deferred until later (the handler just sets a flag variable). It might be the case that your script simply does not get to reading the flag variable before those 5 seconds are up. Try adding something in sub handler that logs receipt of the signal, so you can verify whether you actually receive it and are just too late to act upon it.

CU
Robartes-

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-24 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found