Junior — Middle
How can you terminate or forcibly stop a zombie process in an operating system?
sobes.tech AI
Answer from AI
A zombie process is a process that has finished execution, but its parent process has not yet read its exit status (did not call wait). In the system, it occupies an entry in the process table but does not use CPU resources.
It is not possible to forcibly terminate a zombie process directly, as it has already finished. To get rid of zombies, you need to:
- Terminate or restart the parent process that did not call wait. In this case, init (PID 1) will become the new parent of the zombie, and it will automatically call wait, cleaning up the zombie.
- Send the SIGCHLD signal to the parent process so that it handles the termination status of its child processes.
Example command to send a signal to the parent:
kill -s SIGCHLD <Parent_PID>
If the parent does not respond, you can terminate it:
kill -9 <Parent_PID>
After that, init will adopt the zombie and clean it up.