What is Zombie Process in Linux?

A zombie process is a process whose execution is completed but it still has an entry in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child's exit status. Once this is done using the wait() system call, the zombie process is eliminated from the process table. This is known as reaping the zombie process.

Zombie Process Life Cycle Parent Process Child Process (Running) fork() Child Process (Exits) exit() Zombie Process (Dead + Entry) Parent Process calls wait() wait() - reaps zombie Process Removed from Table

How Zombie Processes Are Created

When a child process terminates using the exit() system call, all its memory and resources are deallocated. However, its entry in the process table remains until the parent process reads its exit status using wait(). During this period, the child becomes a zombie process.

Characteristics of Zombie Processes

  • All memory and resources are deallocated when the process terminates, but the process table entry remains available.

  • The exit status can be read by the parent process using the wait() system call. After that, the zombie process is removed from the system.

  • If the parent process does not call wait(), the zombie process remains in the process table, creating a resource leak.

  • Zombie processes retain their process ID (PID) even though they consume no other system resources.

Dangers of Zombie Processes

While zombie processes don't consume memory or CPU resources, they do retain their process ID. If there are too many zombie processes, all available process IDs become monopolized, preventing new processes from starting.

The presence of many zombie processes also indicates poor programming practices or potential operating system bugs, especially if their parent processes are no longer running. Under heavy loads, this can create serious system issues.

Eliminating Zombie Processes

Zombie processes can be eliminated by sending the SIGCHLD signal to the parent process using the kill command. This signal instructs the parent to clean up the zombie using wait()

kill -s SIGCHLD parent_pid

If the parent process refuses to reap the zombie, the parent itself may need to be terminated. When a parent process dies, its zombie children are automatically adopted by the init process (PID 1), which will properly clean them up.

Prevention

Proper programming practices can prevent zombie processes −

  • Always call wait() or waitpid() to reap child processes

  • Use signal handlers to catch SIGCHLD and automatically reap children

  • Use fork() and exec() properly with appropriate cleanup

Conclusion

Zombie processes are dead processes that retain process table entries until reaped by their parent. While they don't consume system resources, too many zombies can exhaust available process IDs. Proper use of wait() system calls and signal handling prevents zombie accumulation and ensures system stability.

Updated on: 2026-03-17T09:01:38+05:30

21K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements