How the fork() System Call Actually Works in Linux
The fork() System Call
pid_t pid = fork(); if (pid == 0) { printf("I am the child!\n"); } else { printf("I am the parent of %d!\n", pid); } ⚡ Copy-on-Write (COW)
Rather than copying gigabytes of RAM during fork(), the kernel marks all page table entries as read-only. A page is physically cloned only when one process attempts to write to it.
Explore the full interactive process lifecycle on Binary Dose.
原文:https://www.a8q9.cn/en/article/how-the-fork-system-call-actually-works-in-linux-d623b5.html