- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
A diagram that demonstrates the creation and termination of a zombie process is given as follows −
Salient points of Zombie Processes
Some of the salient points related to zombie processes are as follows −
- All the memory and resources allocated to a process are deallocated when the process terminates using the exit() system call. But the process’s entry in the process table is still available. This process is now a zombie process.
- The exit status of the zombie process zombie process can be read by the parent process using the wait() system call. After that, the zombie process is removed from the system. Then the process ID and the process table entry of the zombie process can be reused.
- If the parent process does not use the wait() system call, the zombie process is left in the process table. This creates a resource leak.
- If the parent process is not running anymore, then the presence of a zombie process indicates an operating system bug. This may not be a serious problem if there are a few zombie processes but under heavier loads, this can create issues for the system such as running out of process table entries.
- The zombie processes can be removed from the system by sending the SIGCHLD signal to the parent, using the kill command. If the zombie process is still not eliminated from the process table by the parent process, then the parent process is terminated if that is acceptable.
Dangers of Zombie Processes
Zombie processes don't use any system resources but they do retain their process ID. If there are a lot of zombie processes, then all the available process ID’s are monopolized by them. This prevents other processes from running as there are no process ID’s available.
The presence of zombie processes also indicates an operating system bug if their parent processes are not running anymore. This is not a serious problem if there are a few zombie processes but under heavier loads, this can create issues for the system.
Killing Zombie Processes
Zombie processes can be killed by sending the SIGCHLD signal to the parent, using the kill command. This signal informs the parent process to clean up the zombie process using the wait() system call. This signal is sent with the kill command. It is demonstrated as follows −
kill -s SIGCHLD pid
In the above command, the pid is the process ID of the parent process.
- Zombie and Orphan Processes in Linux
- Linux Process Monitoring
- Process Synchronization in Linux
- What is the maximum number of threads per process in Linux?
- What are Zombie Computer?
- Process Representation in Linux System
- What are the process states in Windows and Linux?
- How to execute zombie and orphan process in a single C program?
- What is Process Suspension and Process Switching?
- What are the five process states in the Linux kernel ?
- What is Process Scheduling?
- What is process termination?
- How to create a process in Linux?
- How to Find the List of Daemon Processes and Zombie Processes in Linux
- What is GRUB in Linux?