12.
MathWorks aptitude question, verified with a worked answer. Free to practise - no sign-up.
12. (Embedded Question) Zombie process
Which of the following statements are correct?
- Zombie process can be killed by SIGKILL
- Zombie can be removed by wait()
- Zombie is created when a child terminates before the parent performs a wait.
Pick ONE option
Show answer & explanation
Zombie processes are terminated child processes whose exit status has not yet been read by the parent. Statement 2 is correct: the parent process calling wait() or waitpid() will collect the zombie's exit status and remove it. Statement 3 is correct: zombies exist precisely because a child has terminated but the parent hasn't called wait() yet. Statement 1 is incorrect: SIGKILL cannot kill a zombie because zombies are already dead—they are not running processes, only kernel table entries awaiting parent collection.
Step-by-step Derivation:
Zombie process behavior:
- A zombie exists after child process terminates but before parent calls wait()
- It occupies a process table entry to store exit status
- It cannot be killed by any signal (including SIGKILL) because it's not executing code
- Only the parent's wait()/waitpid() call removes it from the process table
- If parent dies without calling wait(), the zombie is adopted by init, which collects it
Statement 1 (FALSE): SIGKILL kills running processes; zombies are not running
Statement 2 (TRUE): wait() system call collects child's exit status and frees the zombie
Statement 3 (TRUE): Definitional—zombies exist in exactly this scenario
Answer: B (Only 2 and 3)