What are zombie and orphan processes?
Interview preparation resource from Gate Smashers.
A zombie is a process that has finished but still has a process-table entry because its parent has not collected the exit status. An orphan is a still-running process whose parent terminated first.
When a child terminates, the kernel keeps a small record containing its PID and exit status until the parent calls wait() or a related function. During this period the child is a zombie: it executes no instructions and consumes no CPU, but too many zombies can exhaust process-table entries.
An orphan has not terminated. The operating system reparents it to a designated system process, which later collects its exit status. Orphans can continue doing normal work; zombies cannot because their execution has already ended.
The OS must still retain enough information to report the child's termination status to its parent, which creates a zombie. An orphan is different because it is still running; the system simply gives another process responsibility for eventually collecting its status.
