A parent process is a running process that creates another process, called its child, and remains responsible for that child until the child terminates and its exit status is collected. In the study of processes & scheduling within operating systems, the parent-child relationship is the backbone of the process tree: every process except the very first one has exactly one parent at any moment.
The relationship matters far beyond bookkeeping. The parent decides what the child inherits, such as environment variables, open file handles and security credentials, and it controls cleanup after termination. A parent that neglects its children leaves behind zombie entries, leaks resources or loses track of failures in the programs it started.
How a parent process creates a child
A parent process creates a child through a process creation system call, and the exact mechanism differs between operating system families. On Unix-like systems such as Linux and macOS, the classic pattern is `fork()` followed by `exec()`: fork() duplicates the calling process, and the new copy then replaces its program image with exec(). On Windows, a single call, `CreateProcess`, builds the new process and loads the target program in one step.
Modern kernels make duplication cheap through copy-on-write: parent and child initially share the same physical memory pages, and a page is copied only when one side writes to it. Variants such as vfork(), posix_spawn() and Linux clone() give finer control over what is shared and what is copied, which is why threads and containers are built on the same primitives.
The following table compares the main creation interfaces that a parent process uses on common platforms.
| Interface | Platform | What the parent gets back | Typical use |
|---|---|---|---|
| fork() | Unix-like | Child PID in parent, 0 in child | Shells, servers that pre-fork workers |
| posix_spawn() | POSIX systems | Child PID | Launching programs without a full copy |
| clone() | Linux | Child thread or process ID | Threads, containers, namespaces |
| CreateProcess | Windows | Process and thread handles | Launching any executable |
What the child inherits from its parent
A child process starts with a set of attributes copied or derived from its parent, and knowing this set prevents many security and resource bugs. Inheritance is deliberate: it lets a shell pass its working directory and environment to every command, and it lets a server hand an already open socket to a worker.
The table below summarizes typical inheritance behavior on Unix-like systems, with Windows noted where it differs.
| Attribute | Inherited on Unix-like systems | Notes |
|---|---|---|
| Environment variables | Yes, copied | Windows also copies the environment block by default |
| Open file descriptors | Yes, unless marked close-on-exec | Windows inherits only handles marked inheritable |
| User and group IDs | Yes | Setuid programs can change them after exec |
| Working directory | Yes | Child may change it independently |
| Signal handlers | Reset to default after exec | Ignored signals stay ignored |
| Memory contents | Copied after fork, replaced by exec | Copy-on-write keeps the copy cheap |
Leaked file descriptors are a common failure: a parent that opens a log file or a network connection without the close-on-exec flag passes it to every child, which can keep ports busy or expose sensitive files to an untrusted program.
Waiting, exit status and zombie processes
A parent process is expected to reap its children by calling wait(), waitpid() or, on Windows, by waiting on the process handle and reading the exit code. When a child exits, the kernel keeps a small record in the process control block that holds the exit status until the parent reads it.
If the parent never collects that status, the finished child stays in the process table as a zombie process. A zombie uses no CPU time and almost no memory, but each one occupies a process ID, and thousands of them can exhaust the PID limit and block new process creation. On Unix-like systems, the kernel sends the parent a SIGCHLD signal when a child changes state, so well-designed parents reap children asynchronously in a signal handler or event loop.
The following table describes how the parent-child state combinations play out.
| Situation | Resulting state | Who cleans up |
|---|---|---|
| Child exits, parent waits | Normal termination | Parent reaps immediately |
| Child exits, parent never waits | Zombie process | Nobody until the parent exits |
| Parent exits first | Orphan process | Adopted by init or a subreaper |
| Parent ignores SIGCHLD explicitly | No zombie created | Kernel discards the status |
Parent process versus related process roles
The parent role is relative, not absolute: almost every process is both a child of one process and a potential parent of others. On Linux the root of the tree is PID 1, usually systemd or another init system, while on Windows the tree begins with system processes such as smss.exe and wininit.exe. The term is also distinct from a process group or session, which group processes for job control and terminal signals rather than for creation and cleanup.
When a parent dies before its children, those children become orphan processes and are re-parented. Linux adopts them to PID 1 or to the nearest ancestor marked as a child subreaper with prctl(PR_SET_CHILD_SUBREAPER), a feature that container runtimes and service managers use to keep reaping under control. Windows behaves differently: it records only the parent process ID at creation time and does not re-parent, so the stored ID can later point to an unrelated process that reused the number.
Practical responsibilities of a well-behaved parent
Software that launches other programs, from shells and build tools to web servers and process supervisors, takes on a set of parent responsibilities that determine its reliability. The following decision table summarizes the main design choices.
| Requirement | Recommended practice | Reason |
|---|---|---|
| Avoid zombies | Reap in a SIGCHLD handler or event loop | Frees PIDs promptly |
| Avoid leaked handles | Set close-on-exec on every descriptor | Child sees only what it needs |
| Detect child failure | Check the exit status and signal | Crashes do not go unnoticed |
| Stop children cleanly | Send SIGTERM, then SIGKILL after a timeout | Gives children time to flush data |
| Run as PID 1 in a container | Use a minimal init that reaps orphans | Prevents zombie buildup |
- Check return values of fork and spawn calls, because creation fails when PID or memory limits are reached.
- Avoid fork in multithreaded parents unless exec follows immediately, since only the calling thread is duplicated and locks may stay held.
- Limit child fan-out with a pool or semaphore, so a burst of work cannot trigger a fork bomb effect.
Stripped to the essentials
A parent process is a program that starts another program. Think of a manager who hires a temporary worker: the manager gives the worker some tools and instructions, and when the job is done, the manager signs off on the result.
If the manager never signs the final paperwork, the worker is gone but still listed on the payroll. Computers have the same problem, which is why a parent should always collect the result of each child it started.
Where it is applied
A web hosting team runs an older application server that pre-forks eight worker processes from one master process on a Linux machine. The master is the parent: it opens the listening socket on port 443 once, forks the workers so that each inherits the socket, and then monitors them.
When a worker crashes after a memory error, the master receives SIGCHLD, calls waitpid() to read the exit signal, logs the failure and forks a replacement within milliseconds. Because the master reaps every child immediately, the process table stays clean even after weeks of uptime, and visitors see no interruption in service while individual workers come and go.