What You Will Learn
This chapter dives deep into Linux process creation internals. You will understand how the kernel tracks processes via process accounting, how clone() is the real engine behind threads and fork(), how to measure and compare process creation speed, and exactly which attributes a child process inherits or resets during fork() and exec(). These are critical topics for Linux systems programming interviews and production work.
Key Concepts
Chapter Topics
Learn how the Linux kernel records resource usage for every process that terminates. Understand the acct structure, acct() system call, comp_t encoding, and how to read accounting files programmatically.
Understand clone(), the low-level primitive behind all Linux threads and processes. Learn how it differs from fork() and how threading libraries use it internally.
A deep dive into every important clone() flag — CLONE_VM, CLONE_FILES, CLONE_THREAD, CLONE_SIGHAND, CLONE_NEWNS, and more. Understand exactly what each flag shares between parent and child.
Learn the special waitpid() flags needed to wait for children created by clone() — __WCLONE, __WALL, and __WNOTHREAD — and understand when each is needed.
Benchmark and compare fork(), vfork(), and clone() performance. Understand why vfork() and clone() are faster, and why the difference shrinks once exec() is involved.
A complete reference of all process attributes and what happens to them across fork() and exec(). Covers file descriptors, signals, timers, IPC, capabilities, threads, and more.
Recommended Learning Path
Ready to Master Linux Process Internals?
Start with Process Accounting and work through each topic in order for the best understanding.
