How to detect SIGTERM originated from halt of system?

BlaineZ

New Member
Joined
May 5, 2022
Messages
1
Reaction score
0
Credits
15
I have a signal handler implemented to receive the signal SIGTERM. However, I cannot find a way to determine if the SIGTERM originated from a Halt of the system. I looked at the output from the runlevel command, but it's "N N". I was hoping I'd see "3 0", where 0 is the runlevel for Halt. This is a SLES based Linux.

I looked at the setting up a sa_sigaction to get the siginfo_t pointer, but detected no si_code or si_errno (they are both 0) and the si_pid is 1, but this does not tell me that a Halt is occurring.

Does anyone know how to determine when a SIGTERM is received that a Halt of the system is occurring? Note, I want to distinguish between a Halt and a Reboot.
 


As far as the system is concerned and any applications - a SIGTERM is just a signal. I could be wrong, but I don’t think there’s any way of knowing who or what issued it.
SIGTERM could also be sent directly to a process by a user via the kill command.
 

Staff online


Latest posts

Top