The fork() function

On a Unix-based system, the fork() function is used to create processes. The fork() function is a relatively simple system call provided by the operating system that takes the current process, and creates a duplicate child version of the process. Everything about the parent and child processes is the same, including opened file handles, memory, and so on, with the key difference being that the child process has a new process ID.

In Chapter 12, Learning to Program POSIX and C++ Threads, we will discuss threads (which are more commonly used for system programming than processes). Both threads and processes are scheduled by the operating system; the main difference between a thread and a process is that a child and parent ...

Get Hands-On System Programming with C++ 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.