Process Creation: Parent-Child Relationships
What you'll learn: How processes form family trees and what it means for one process to be the parent or child of another.
The Process Family Tree
When a process uses fork() to create a new process, the original becomes the parent and the newly created one becomes the child. This creates a hierarchical relationship, much like a family tree—every process (except the very first one the OS starts) has exactly one parent, but a parent can have many children.
How Parent-Child Relationships Work
After fork() executes:
- The parent process continues running with its original Process ID (PID)
- The child process gets a brand-new PID
- The child is an almost-identical copy of the parent at the moment of the fork
- Both processes know about each other: the parent receives the child's PID from
fork(), and the child can query its parent's PID
The Process Tree Structure
Think of it like a company org chart. The very first process (often called init or systemd on Unix-like systems) sits at the top. Every process it creates becomes its child, and when those children create processes, those become grandchildren of the original. This forms a tree structure where you can trace any running process back to the root.
If a parent process terminates before its child, the child becomes an orphan and is typically adopted by the root process. If a child terminates but the parent hasn't acknowledged it yet, the child becomes a zombie—its PCB remains in the system until the parent reads its exit status.
Key Takeaway: Processes organize in a tree hierarchy through parent-child relationships established by fork(), where each process has one parent and can have multiple children, forming the basis of process management in modern operating systems.