Skip to main content

In Linux, a zombie process is a state that a child process enters when it has finished executing, but its exit status has not yet been collected by its parent process. Zombie processes are essentially dead processes that are waiting for their parent process to retrieve their exit status.

When a process terminates in Linux, it doesn't immediately disappear from the process table. Instead, it becomes a zombie process until the parent process acknowledges the child's termination and retrieves its exit status. Once the parent process collects the exit status, the zombie process is removed from the process table, and its resources are released.

Zombie processes are typically harmless and consume very little system resources. However, if a parent process fails to collect the exit status of its child processes, a large number of zombie processes can accumulate and potentially lead to issues. To prevent this, it's important for the parent process to regularly call the wait() system call or one of its variants (e.g., waitpid()) to collect the exit status of its child processes and clean up zombie processes. To test this, in c you can create a child process using fork() and run it for 60 seconds. After running the c program, if you look at your system monitor (or top, htop commands) you'll see your zombie there. It's supposed to be dead, but it isn't, hence zombie. 

In most cases, well-written programs and system utilities properly handle child processes, preventing zombie processes from becoming a problem.

Tags

x

Work

Therefore logo
80 Atlantic Ave, Toronto, ON Canada
Email: hello@therefore.ca
Call us: +1 4166405376
Linkedin

Let us know how we can help!