UNIX implements through the fork() and exec() system calls an elegant two-step mechanism for process creation and execution. fork() is used to create the image of a process using the one of an existing one, and exec is used to execute a program by overwriting that image with the program's one. This separation allows to perform some interesting housekeeping actions in between, as we'll see in the following lectures.

A call to fork() of the form:

#include <sys/types.h>

pid_t childpid;
childpid = fork(); /* child's pid in the parent, 0 in the child */