SIGKILL信号处理 [英] SIGKILL signal handling

查看:410
本文介绍了SIGKILL信号处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果linux进程正在等待I/O(即它处于SLEEP状态)并且针对它发出SIGKILL信号,则在终止(STOPPED状态)时它将通过RUNNINGREADY状态?

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?

换句话说,对于处理诸如SIGKILL生成的系统中断的进程,是否有必要通过RUNNINGREADY状态?

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 ?

知道正常情况下一个进程可以处理来自内核的中断,并且知道SIGKILL具有杀死一个无响应信号的相当矛盾的目的,所以我怀疑要给被杀死的进程提供多少控制权(如果有的话)完全没有.

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.

推荐答案

内核将信号传递"给进程,因此从进程A向进程B发送信号时使用内核.交付SIGKILL时,内核不允许进程(用户模式)进行任何活动,特别是进程启动:atexit调用,_exit.没有.该过程仅被系统破坏.这涉及内核模式下的一些活动.缓冲的数据丢失. SYSV信号量和其他内核持久性内存对象保留在内存中.可能真是一团糟.

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.

如果内核内存中的某些内容导致挂起,请在linux中使用sysrq接口:

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.

这就是为什么使用SIGKILL绝对是万不得已的原因,因为您不知道自己在破坏什么.而且它不能解决所有挂起的问题.

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.

您到底在做什么?

这篇关于SIGKILL信号处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆