FORK(2) COMMAND REFERENCE FORK(2)
NAME
fork - create a new process
SYNOPSIS
pid = fork()
int pid;
DESCRIPTION
Fork causes creation of a new process. The new process
(child process) is an exact copy of the calling process
(parent process) except for the following:
The child process has a unique process ID.
The child process has a different parent process ID
(i.e., the process ID of the parent process).
The child process has its own copy of the parent's
descriptors. These descriptors reference the same
underlying objects, so that, for instance, file
pointers in file objects are shared between the child
and the parent, so that a lseek(2) on a descriptor in
the child process can affect a subsequent read or write
by the parent. This descriptor copying is also used by
the shell to establish standard input and output for
newly created processes as well as to set up pipes.
The child processes resource utilizations are set to 0;
see setrlimit(2).
DIAGNOSTICS
Fork will fail and no child process will be created if one
or more of the following are true:
[EAGAIN]
The system-imposed limit on the total number of
processes under execution, NPROC, would be exceeded.
[EAGAIN]
The system-imposed limit on the total number of
processes under execution by a single user, MAXUPRC,
defined in <sys/param.h>, would be exceeded.
[ENOMEM]
Insufficient space exists in the swap area for the child
process.
RETURN VALUE
Upon successful completion, fork returns a value of 0 in pid
to the child process and returns the process ID of the child
process in pid to the parent process. Otherwise, a value of
-1 is returned to the parent process, no child process is
Printed 10/17/86 1
FORK(2) COMMAND REFERENCE FORK(2)
created, and the global variable errno is set to indicate
the error.
SEE ALSO
execve(2), setrlimit(2), vfork(2), wait(2).
Printed 10/17/86 2
%%index%%
na:72,63;
sy:135,192;
de:327,1153;
di:1480,628;
rv:2108,376;2628,90;
se:2718,203;
%%index%%000000000115