Whenever I give reboot command, my process is receiving SIGTERM signal and is handling it. I don't want to handle it if the SIGTERM is due to reboot.
Please suggest me any idea.
Is there any way to send kill -9 signal to my process when I do system("reboot")?
I am using Cent OS (Linux).
whenever i give reboot command,my process is receiving SIGTERM signal and is handling it. I dont want to handle it if the SIGTERM is due to reboot.
You may try to run /sbin/runlevel in your signal handler (well, maybe process spawning is not even possible in a signal handler though) to get the current runlevel. Runlevel 6 is reboot.
Is there any way to send kill -9 signal to my process when i do system(reboot).
If your process is started by init scripts you can change the script so that stop is performed with kill -KILL instead of something else.
I am using Cent OS(linux).
I don't know if the following applies for CentOS.
In Debian, all remaining processes (the ones alive after all kill scripts have been ran) are signaled by /etc/init.d/sendsigs. If you have administrator access you can try to customize it so a specially named process (yours) get KILLed without TERMing before.
Still, all pids related in /run/sendsigs.omit and all pids related in files in /run/sendsigs.omit.d/ don't receive any signal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With