Junior — Middle
How can a zombie process stuck in the Linux operating system be eliminated?
sobes.tech AI
Answer from AI
A zombie process in Linux is a process that has finished execution, but its parent process has not yet called wait() or an equivalent function to retrieve its exit status. To eliminate zombies:
- Ensure that the parent process correctly handles signals for child process termination (e.g., SIGCHLD) and calls
wait()orwaitpid(). - If the parent process does not respond, it can be terminated, and the zombie processes will be inherited by the
initprocess (PID 1), which will properly clean them up.
Example command to find zombies:
ps aux | grep Z
Then, you can find the parent process and restart or terminate it. Ideally, the code of the parent process should be fixed to handle child processes correctly.