僵尸进程 vs 已关闭进程?

13

“僵尸进程”和“死亡进程”之间有区别吗?我在维基百科文章中发现这两个术语是相同的。既然如此,为什么需要对同一进程使用两个不同的术语:

https://en.wikipedia.org/wiki/Zombie_process


相对于计算机业务的其他方面,只有两个术语来描述某些东西已经做得很好了。数据库中的每个内容都有5个以上的名称,通常会重复使用相同的单词来表示不同的部分。https://askubuntu.com/questions/201303/what-is-a-defunct-process-and-why-doesnt-it-get-killed - chicks
3个回答

9

对于Linux来说,“defunct”和“zombie”进程是一样的。

man ps命令中可以得到以下信息:

被标记为<defunct>的进程是死亡进程(也称为“僵尸进程”),它们会因为其父进程没有适当地销毁它们而保留下来。如果父进程退出,这些进程将由init(8)进程销毁。

PROCESS STATE CODES
    Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
    D    uninterruptible sleep (usually IO)
    R    running or runnable (on run queue)
    S    interruptible sleep (waiting for an event to complete)
    T    stopped by job control signal
    t    stopped by debugger during the tracing
    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

2
正文:
如Achal所说,defunct是由ps添加的。严格来说,它们不是同一件事。
例如,在下表中只有tid 10941是僵尸进程。其他线程处于状态D而不是Z。
$ grep prometheus foo/bar/sos_commands/process/ps_-elfL
4 Z root      10941  10920  10941  0    6  80   0 -      0 exit   Mar14 ?  00:11:41 [prometheus] <defunct>
1 D root      10941  10920  11010  0    6  80   0 - 621811 wait_o Mar14 ?  00:11:08 [prometheus] <defunct>
1 D root      10941  10920  11025  0    6  80   0 - 621811 wait_o Mar14 ?  00:08:13 [prometheus] <defunct>
1 D root      10941  10920  11057  0    6  80   0 - 621811 wait_o Mar14 ?  00:11:12 [prometheus] <defunct>
1 D root      10941  10920  11060  0    6  80   0 - 621811 wait_o Mar14 ?  00:11:42 [prometheus] <defunct>
1 D root      10941  10920  11298  0    6  80   0 - 621811 wait_o Mar14 ?  00:11:05 [prometheus] <defunct>


好的观点。谢谢你。那么Z和D之间的真正区别是什么? - user2420079
1
Z 死了,而 D 正在睡觉。 - wenjianhn
ps 的 man 页面显示:进程状态代码D:不可中断的睡眠(通常是 IO) Z:僵尸进程,已终止但未被其父进程回收 - Robin Hsu

1

Zombiedefunct是一样的。 ZOMBIE是进程状态之一,而没有defunct状态,您可以从内核源代码中看到。

enum proc_state {
    UNUSED,   /*** processes in initial state **/
    EMBRYO, 
    SLEEPING,
    RUNNABLE, 
    RUNNING, 
    ZOMBIE   /** processes in final state **/
};
僵尸状态是指进程已经退出但是还没有被清理的状态。

您可以打开proc(1)的手册,查看/ proc / [pid] / stat 有关该进程的状态信息。这被ps(1)使用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接