Zombie vs Defunct processes?
Asked Answered
T

3

13

Is there a difference between zombie and defunct processes? I have found the wikipedia article where it is written that this two are the same. In that case why it is needed to have 2 different terms for the same process:

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

Tack answered 26/12, 2017 at 10:44 Comment(1)
Only having 2 terms for something is doing pretty good relative to the rest of the computer business. Everything in a database has 5+ names, often reusing the same words for different parts. askubuntu.com/questions/201303/…Salenasalene
T
9

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
Thirtyeight answered 31/1, 2018 at 11:56 Comment(0)
L
2

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>

Legator answered 17/6, 2019 at 8:57 Comment(3)
Good point. Thank you. So what is the real difference between Z and D?Tack
Z is dead while D is sleeping.Legator
man page of ps shows: PROCESS STATE CODES D: uninterruptible sleep (usually IO) Z: defunct ("zombie") process, terminated but not reaped by its parentBikini
B
1

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).

Brochu answered 31/1, 2018 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.