Manual page for FORK(2V)
fork - create a new process
SYNOPSIS
int fork()
SYSTEM V SYNOPSIS
pid_t fork()
DESCRIPTION
fork()
creates a new process. The new process (child process) is an exact copy of the
calling process except for the following:
- The child process has a unique process
ID.
The child process
ID
also does not match any active process group
ID.
- The child process has a different parent process
ID
(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 an
lseek.2v
on a descriptor in the child process can affect a subsequent
read.2v
or
write.2v
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 process has its own copy of the parent's open
directory streams
(see
directory.3v
Each open directory stream in the child process shares
directory stream positioning with the corresponding directory
stream of the parent.
- All
semadj
values are cleared; see
semop.2
- The child processes resource utilizations are set to 0; see
getrlimit.2
The
it_value
and
it_interval
values for the
ITIMER_REAL
timer are reset to 0; see
getitimer.2
- The child process's values of
tms_utime(),
tms_stime(),
tms_cutime(),
and
tms_cstime()
(see
times.3v
are set to zero.
- File locks
(see
fcntl.2v
previously set by the parent are not inherited by the child.
- Pending alarms
(see
alarm.3v
are cleared for the child process.
- The set of signals pending for the child process is cleared
(see
sigvec.2
RETURN VALUES
On success,
fork()
returns
0 to the child process and returns
the process
ID
of the child process to the parent process.
On failure,
fork()
returns
-1 to the parent process,
sets
errno
to indicate the error, and no child process is created.
ERRORS
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 would be exceeded.
This limit is determined when the system is generated.
The system-imposed limit on the total number of processes under execution by
a single user would be exceeded.
This limit is determined when the system is generated.
- ENOMEM
-
There is insufficient swap space for the new process.
SEE ALSO
execve.2v
getitimer.2
getrlimit.2
lseek.2v
read.2v
semop.2
wait.2v
write.2v
Created by unroff & hp-tools.
© somebody (See intro for details). All Rights Reserved.
Last modified 11/5/97