Unit content
Unix process creation, program replacement and termination
Unix-like systems build process management from several operations with distinct meanings.
fork
fork creates a child process from the caller. Parent and child continue from the point after the call but receive different return values.
Modern systems can initially share physical pages using copy-on-write: a private page is copied only when one process modifies it.
exec
The exec family does not create another process. It replaces the current process's program image while retaining the process identity and selected operating-system state.
A shell can therefore implement a command approximately as
fork → child → exec(command)
Termination and waiting
A terminating process leaves an exit status for its parent. Operations such as wait collect that status. Until collection, a terminated child can remain as a zombie process-table entry.
Composition
Separating creation, program replacement and waiting makes the Unix model unusually composable: shells, pipelines, servers and other applications can arrange process relationships before choosing which program each child executes.