previous | start | next

Creating a Process

      #include <unistd.h>
      #include <sys/types.h>

      pid_t fork();
   

The fork() function is a system call.

The new child process gets a copy of the code and current state of all variables.

For one call to fork(), there are two returns.

The return value to the child is 0.

The return value to the parent is the pid of the new child.

Execution continues at the same instruction in both the parent's and the child's copy when fork() returns.

The child does NOT start over at the beginning of its copy of the program.



previous | start | next