FORK(2)

NAME
fork - create a child process

SYNOPSIS
#include <unistd.h>
int fork(void);

DESCRIPTION
fork() creates a child process the differs from the parent process only in its PID. On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of execution. On failure, a negative value will be returned in the parent's context and no child process will be created.

Under linux, fork() is implemented using copy on write pages, so the only penalty incured by fork is the time and memory required to duplicate the parent's page tables, and to create a unique task_struct for the child.

ERRORS
-EAGAIN is returned if fork() cannot allocate sufficient memory to copy the parent's page tables and allocate a task_struct for the child.

FILES
linux/kernel/fork.c
/usr/include/linux/sys.h
/usr/include/unistd.h

SEE ALSO
exec(2)

BUGS
Currently, the Linux process table is limited to 64 processes.