How to detect pending system shutdown on Linux?

Posted by Rajorshi on Stack Overflow See other posts from Stack Overflow or by Rajorshi
Published on 2010-05-14T07:00:49Z Indexed on 2010/05/14 7:04 UTC
Read the original article Hit count: 269

Filed under:
|

Hi, I am working on an app where I need to detect system shutdown. However, I have not found any reliable way get a notification on this event. I know that on shutdown, my app will receive a SIGTERM signal followed by a SIGKILL. What I want to know is if there is someway to query if a SIGTERM is part of a shutdown sequence? Does any one know if there is a way to query that programmatically (C API)? As far as I know, the system does not provide any other method to query for an impending shutdowm. If it does, that would solve my problem as well. I have been trying out runlevels as well, but change in runlevels seem to be instantaneous and without any prior warnings.

© Stack Overflow or respective owner

Related posts about system-shutdown

Related posts about linux