SIGKILL signal handling

前端 未结 2 707
后悔当初
后悔当初 2021-01-02 21:38

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

相关标签:
2条回答
  • 2021-01-02 22:08

    In addition to jim mcnamara's answer:

    SIGKILL (kill -9) cannot be handled.

    See the answer at https://stackoverflow.com/a/2541618/1456519 for more.

    0 讨论(0)
  • 2021-01-02 22:14

    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?

    0 讨论(0)
提交回复
热议问题