Processes & the Process Abstraction

an orphan process

Imagine a child whose parent leaves before the child does, the child is still alive and going about its day, but the person responsible for it is gone. The system handles this by assigning a guardian. An orphan process is a process that is still running while its parent has already terminated; it has lost its original parent but is not abandoned, because the OS gives it a new one.

When a parent process exits while one of its children is still running, that child becomes an orphan. The OS does not leave it parentless: it re-parents the orphan to the init process (PID 1), which becomes the child's new parent. The orphan keeps running normally, unaffected, but now if you ask for its parent's PID you will see 1. This re-parenting is essential because of cleanup duties: when the orphan eventually finishes, some parent must reap it, and init, as the adoptive parent, performs that reaping so the orphan does not become a permanent zombie.

Orphans are common and usually harmless, they arise naturally whenever a long-running child outlives the shell or program that started it. The key contrast to keep straight is orphan versus zombie. An orphan is still alive (running) but its parent died first; a zombie is already dead (terminated) but not yet reaped by its parent. The two are sometimes linked: an orphan that later terminates would become a zombie, except that its adoptive parent init promptly reaps it, so in practice adopted orphans are cleaned up cleanly.

You start a long-running background job from a shell, then close the shell. The job keeps running, but its parent (the shell) is gone, so it is re-parented to init; checking it now shows parent PID 1.

Lose your parent and you are adopted by init, not abandoned.

Do not confuse orphan with zombie. An orphan is still running but its parent died first; a zombie has already terminated but has not yet been reaped.

Also called
orphanre-parented process孤兒行程被收養的行程