How fork works

In theory, the job description of the fork(2) system call can be crystallized down to one simple statement: create an identical copy of the calling process. The terminology we shall repeatedly encounter is as follows: the process-calling fork is called the parent and the newly created, newborn process is called the child.

Please note that, to begin with at least, we shall keep the discussion on how fork works purely conceptual and simple; later, we shall delve deeper and clarify how the OS performs several necessary optimizations.

Fork is a system call; thus, the real work of process creation is carried out by the OS under the hood. Recall from Chapter 2, Virtual Memory, that the virtual address space (VAS) of a process is ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.