Process creation, waiting and exit
easy 7 minA process owns an address space, descriptors and a place in the process tree.
Video lesson · Chapter 1 of 8
Why finished children still occupy slots
Theory
Read or listen first. About 2 min.
What it is
A process owns an address space, descriptors and a place in the process tree. Fork creates a child with initially shared copy-on-write pages. Exec replaces its program while preserving its process identity. On exit the kernel retains a small record until a parent or designated reaper consumes the status. That record can occupy a process slot even though the program has finished.
Why it exists
A job runner creates short-lived converters. RSS stays stable, yet eventually it cannot create another process. Count children by state and parent, then compare the counts across two intervals. A growing set of zombies under one parent points to a missing wait path. Increasing the PID limit only delays recurrence if exits keep accumulating.
If the task count rises but no children are in Z, inspect live worker growth and the group PID limit.
Why finished children still occupy slots
Inside this chapter
- The Process Control Block (PCB) structure
- Linux represents each schedulable task with a task_struct and references to shared or private state. Threads can share an address space while having different scheduling states.
- Process States: Running, Interruptible Sleep (S), Uninterruptible Sleep (D)
- R includes running and runnable tasks. S commonly waits for a wakeup that signals can interrupt. D denotes an uninterruptible wait, often in an I/O path.
- Zombie and Orphan processes
- A zombie has exited and awaits collection of its status. An orphan is a live or exited child whose parent disappeared and whose parentage has been reassigned.
- Process creation: fork(), exec(), and Copy-on-Write (CoW) mechanics
- Fork initially shares eligible pages using copy-on-write. A write can allocate a private copy. Exec replaces the child’s address space with the new program.
- Process groups and sessions (setsid, getpgrp)
- A process group lets a shell manage a pipeline as one job. Sessions collect groups and govern controlling-terminal relationships. These boundaries need not match a service’s cgroup.
- Daemon processes and the double-fork pattern
- Traditional daemonization detaches from a terminal through forking and session changes. Under a supervisor, foreground execution often gives the supervisor clearer process ownership and exit status.
How it works
Step through the idea, or press Play.
Before fork. A single process owns its virtual memory mappings.
Understand it
Worked incident
Why finished children still occupy slots
| Observation | Unreaped children (children) | Interpretation |
|---|---|---|
| Baseline | 0 | The supervisor reaps each converter after exit. |
| Incident | 52 | Error-path children exit but the parent skips its wait loop. |
| After intervention | 0 | Reap all completed children and run the error path again. The count should return to its previous floor. |
Choose the next investigation
Summary
The whole topic in one minute.
The child has already exited. The kernel still owes its parent a status record, which a wait operation consumes.
If the task count rises but no children are in Z, inspect live worker growth and the group PID limit.