Zombie vs Defunct processes?
Both Zombie
and defunct
are same. ZOMBIE
is the one of the state of the process
while there is no defunct
state, you can see it from your kernel source code.
enum proc_state {
UNUSED, /*** processes in initial state **/
EMBRYO,
SLEEPING,
RUNNABLE,
RUNNING,
ZOMBIE /** processes in final state **/
};
Zombie state means where it has exited but has not yet been cleaned up.
you can open man page of proc(1)
and see this /proc/[pid]/stat
Status information about the process. This is used by ps(1)
.
For Linux "defunct" and "zombie" processes are the same.
From 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
As Achal said defunct was added by ps. Strictly speaking, they are not the same thing.
For example, only tid 10941 was a zombie in the following table. The other threads were in stat D instead of 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>