If a linux process is waiting for I/O (i.e it is in SLEEP
state) and a SIGKILL
signal is issued against it, upon termination (STOPPED
state) will it pass through RUNNING
or READY
state?
In other words, for a process to handle a system interrupt such as one generated by SIGKILL
is it necessary to pass through RUNNING
or READY
state ?
Knowing that under normal circumstances a process can handle an interrupt from kernel and knowing that SIGKILL
has a quite contradictory purpose of killing an unresponsive signal, I was doubtful about how much control is given to the process being killed, if any at all.
SIGKILL. (signal 9) is a directive to kill the process immediately. This signal cannot be caught or ignored. It is typically better to issue SIGTERM rather than SIGKILL. If the program has a handler for SIGTERM, it can clean up and terminate in an orderly fashion.
The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interrupt the process. This is typically initiated by pressing Ctrl-C, but on some systems, the "delete" character or "break" key can be used. The SIGKILL signal is sent to a process to cause it to terminate immediately (kill).
The SIGSTOP signal stops the process. It cannot be handled, ignored, or blocked.
Signal are "handed off" to a process by the kernel, so sending a signal from processA to processB employs the kernel. When SIGKILL is delivered the kernel does not allow any activity by the process (user mode), specifically process rundown: atexit calls, _exit. Nothing. The process is simply destroyed by the system. This involves some activity in kernel mode. Buffered data is lost. SYSV semaphores and other kernel persistent memory objects are left in memory. It can be a real mess.
If something in kernel memory is causing a hang you use the sysrq interface in linux:
http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/security-sysrq.html
--to perform whatever semblance of an ordered shutdown you can get.
This is why using SIGKILL is an absolute last resort, because you cannot know what you are breaking. And it will not fix all hangs.
What exactly are you working on?
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