xeo*_*eor 13 linux history linux-kernel
在 中man ps
,它清楚地说明了进程在 Linux 上可以具有的不同状态。
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.
Run Code Online (Sandbox Code Playgroud)
即使X
是一个进程状态,它也不应该被看到。但这是正确的吗?是否有一种理论上的方法可以将其视为过程中的状态?还是完全100%不可能?
我对 Linux 内核进行了一些深入研究,但不知道它在内核中的工作原理,也没有任何 C 知识。所以请善待这个理论:)
该DEAD
状态被定义https://github.com/torvalds/linux/blob/master/fs/proc/array.c#L141并在使用https://github.com/torvalds/linux/blob/master/fs /exec.c#L974仅给出返回状态。因此,唯一可以看到的方法是,如果您在https://github.com/torvalds/linux/blob/master/fs/exec.c#L986之前检查进程状态(或稍后在此函数被调用的任何地方)从..)。
如果您尝试杀死一个死进程,它将在https://github.com/torvalds/linux/blob/master/kernel/signal.c#L1363 中被处理并忽略
所以理论上......我认为答案是肯定的。X 作为一种状态在理论上可以被看到,但在现实生活中可能从未出现过。
如果/哪里我错了,请纠正我..我对此完全不确定..