Zombie vs Defunct 进程?
Zombie vs Defunct processes?
僵尸进程和死进程有区别吗?我找到了维基百科文章,其中写道这两个是相同的。在那种情况下,为什么需要为同一过程设置 2 个不同的术语:
对于Linux "defunct"和"zombie"过程是一样的。
来自man ps
:
Processes marked <defunct>
are dead processes (so-called "zombies") that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits.
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
Zombie
和defunct
都是一样的。 ZOMBIE
是state of the process
中的一种,没有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)
.
使用
正如 Achal 所说,defunct 是由 ps 添加的。严格来说,它们不是一回事。
比如下面table中只有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>
僵尸进程和死进程有区别吗?我找到了维基百科文章,其中写道这两个是相同的。在那种情况下,为什么需要为同一过程设置 2 个不同的术语:
对于Linux "defunct"和"zombie"过程是一样的。
来自man ps
:
Processes marked
<defunct>
are dead processes (so-called "zombies") that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits.
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
Zombie
和defunct
都是一样的。 ZOMBIE
是state of the process
中的一种,没有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)
.
正如 Achal 所说,defunct 是由 ps 添加的。严格来说,它们不是一回事。
比如下面table中只有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>