What status must a process receive from its parent process to become a zombie?
sobes.tech AI
Answer from AI
A process becomes a zombie or a "defunct" process when it has finished execution (transitions to the EXIT_ZOMBIE state), but its record still exists in the process table, waiting for its parent process to read its exit status using the wait() or waitpid() system call. Until then, it occupies minimal resources (almost only its entry in the process table), but does not fully release the resources associated with it.
In the process table, such a process is usually marked with <defunct>.
# Example output of the ps command showing a zombie process
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...
someuser 1234 0.0 0.0 0 0 pts/0 Z+ 10:00 0:00 [defunct_process]
...
For the zombie process to disappear, the parent process must call wait() or waitpid(). If the parent process terminates before reading the exit status of its zombie children, these children are adopted by the init process (with PID 1), which automatically calls wait() for its child processes, thereby cleaning up the zombies.
Thus, the main status that a process receives from its parent to become a zombie is the termination state, which the parent has not yet processed through wait* calls.