Zombie process vs Orphan process Zombie process vs Orphan process unix unix

Zombie process vs Orphan process


When a child exits, some process must wait on it to get its exit code. That exit code is stored in the process table until this happens. The act of reading that exit code is called "reaping" the child. Between the time a child exits and is reaped, it is called a zombie. (The whole nomenclature is a bit gruesome when you think about it; I recommend not thinking about it too much.)

Zombies only occupy space in the process table. They take no memory or CPU. However, the process table is a finite resource, and excessive zombies can fill it, meaning that no other processes can launch. Beyond that, they are bothersome clutter, and should be strongly avoided.

If a process exits with children still running (and doesn't kill its children; the metaphor continues to be bizarre), those children are orphans. Orphaned children are immediately "adopted" by init (actually, I think most people call this "reparenting," but "adoption" seems to carry the metaphor better). An orphan is just a process. It will use whatever resources it uses. It is reasonable to say that it is not an "orphan" at all since it has a parent, but I've heard them called that often.

init automatically reaps its children (adopted or otherwise). So if you exit without cleaning up your children, then they will not become zombies (at least not for more than a moment).

But long-lived zombies exist. What are they? They're the former children of an existing process that hasn't reaped them. The process may be hung. Or it may be poorly written and forgets to reap its children. Or maybe it's overloaded and hasn't gotten around to it. Or whatever. But for some reason, the parent process continues to exist (so they aren't orphans), and they haven't been waited on, so they live on as zombies in the process table.

So if you see zombies for longer than a moment, then it means that there is something wrong with the parent process, and something should be done to improve that program.


When a process terminates, its resources are deallocated by the operatingsystem. However, its entry in the process table must remain there until theparent calls wait(), because the process table contains the process’s exit status.A process that has terminated, but whose parent has not yet called wait(), isknown as a zombie process. All processes transition to this state when theyterminate, but generally they exist as zombies only briefly. Once the parentcalls wait(), the process identifier of the zombie process and its entry in theprocess table are released.

Now consider what would happen if a parent did not invoke wait() andinstead terminated, thereby leaving its child processes as orphans. Linux andUNIX address this scenario by assigning the init process as the new parent to orphan processes. The init process periodicallyinvokes wait(), thereby allowing the exit status of any orphaned process to becollected and releasing the orphan’s process identifier and process-table entry.

Source: Operating System Concepts by Abraham, Peter, Greg


An orphan process is a computer process whose parent process has finished or terminated, though it (child process) remains running itself.
A zombie process or defunct process is a process that has completed execution but still has an entry in the process table as its parent process didn't invoke an wait() system call.