163

With commands like top and the gui based System Monitor I can see that at the moment I have several zombie processes.

What are zombie processes?

Do they affect the performance of the system or the application they are zombie to. Do they use too much memory or any memory at all?

4
  • 46
    They are processes that want to eat your cpu ;) Jun 13, 2011 at 22:37
  • 11
    for lunch... :)
    – RolandiXor
    Jun 14, 2011 at 1:57
  • 9
    These processes are dead but not burried . Oct 14, 2015 at 16:13
  • 2
    Eat my CPU?! That's actually terrifying! Nov 17, 2015 at 12:10

5 Answers 5

191

Zombies are DEAD processes. They can not be 'kill' (You cannot kill the DEAD). All processes eventually die, and when they do they become zombies. They consume almost no resources, which is to be expected because they are dead! The reason for zombies is so the zombie's parent (process) can retrieve the zombie's exit status and resource usage statistics. The parent signals the operating system that it no longer needs the zombie by using one of the wait() system calls.

When a process dies, its child processes all become children of process number 1, which is the init process. Init is always waiting for children to die, so that they don't remain as zombies.

If you have zombie processes it means those zombies have not been waited for by their parent (look at PPID displayed by ps -l). You have three choices: Fix the parent process (make it wait); kill the parent; or live with it. Remember that living with it is not so hard because zombies take up little more than one extra line in the output of ps.

Zombies can be identified in the output from the Unix ps command by the presence of a "Z" in the STAT column. Zombies that exist for more than a short period of time typically indicate a bug in the parent program. As with other leaks, the presence of a few zombies isn't worrisome in itself, but may indicate a problem that would grow serious under heavier loads.

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent.

There are also orphan processes which are a computer process whose parent process has finished or terminated.

A process can become orphaned during remote invocation when the client process crashes after making a request of the server.

Orphans waste server resources and can potentially leave a server in trouble (This is the biggest resource difference between zombies and orphans (Except if you see some orphan zombie movie). However there are several solutions to the orphan process problem:

  1. Extermination is the most commonly used technique; in this case the orphan process is killed.

  2. Reincarnation is a technique in which machines periodically try to locate the parents of any remote computations; at which point orphaned processes are killed.

  3. Expiration is a technique where each process is allotted a certain amount of time to finish before being killed. If need be a process may "ask" for more time to finish before the allotted time expires.

A process can also be orphaned running on the same machine as its parent process. In a UNIX-like operating system any orphaned process will be immediately adopted by the special "init" system process. This operation is called re-parenting and occurs automatically. Even though technically the process has the "init" process as its parent, it is still called an orphan process since the process which originally created it no longer exists.

More Info:

4
  • 26
    Ekhm! You CAN kill the dead! You just have to aim for the head. Or have they been lying to us all the time? Nov 29, 2012 at 2:50
  • 1
    init calls wait on all its child processes be it, zombie, orphaned(adopted) and biological(self-spawned)? Oct 18, 2013 at 17:53
  • 1
    acc. to World War Z use camouflage :P Feb 11, 2014 at 6:10
  • Please give a medal to @MarcinKaminski !
    – Andrea
    Jun 29, 2016 at 9:22
24

Zombie processes (also show as <defunct>), aren't real processes at all. They are just entries in the kernel process table. This is the only resource they consume. They do not consume any CPU or RAM. The only danger of having zombies, is running out of space in process table (you can use cat /proc/sys/kernel/threads-max to see how many entries are allowed on your system).

They appear only when their parent process (i.e. process which fork()'ed them) is alive, but did not yet call wait() system function. Once parent dies, the zombies are wait()'ed for by init and disappear.

1
  • 5
    The top `screenshot in this question seems to contradict you? There, the zombie appears to use 100% of 1 CPU, but no memory. Jul 22, 2011 at 11:40
9

When a child process terminates, its death is communicated to its parent so that the parent may take some appropriate action.

A process that is waiting for its parent to accept its return code is called a zombie process.

They have completed their execution but still has an entry in the process table.

1

Zombie processes are processes that have stopped running but their process table entry still exists because the parent process hasn't retrieved it via the wait syscall. Technically each process that terminates is a zombie for a very short period of time but they could live for longer.

Longer lived zombie processes occur when parent processes don't call the wait syscall after the child process has finished. One situation where this occurs is when the parent process is poorly written and simply omits the wait call or when the parent process dies before the child and the new parent process does not call wait on it. When a process' parent dies before the child, the OS assigns the child process to the "init" process or PID 1. i.e. The init process "adopts" the child process and becomes its parent. This means that now when the child process exits the new parent (init) must call waitto get its exit code or its process table entry remains forever and it becomes a zombie

0

You can see in the second line that there is 1 zombie process running on my system.

If you want further details about the zombie process, use the following command:

$ ps axo stat,ppid,pid,comm | grep -w defunct

Killing a Zombie-Process:

$ kill -s SIGCHLD PID

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .