FORK(S) XENIX System V FORK(S)
Name
fork - Creates a new process.
Syntax
int fork ()
Description
fork causes creation of a new process. The new process
(child process) is an exact copy of the calling process
(parent process). This means the child process inherits the
following attributes from the parent process:
environment
close-on-exec flag (see exec(S))
signal handling settings (that is, SIG_DFL, SIG_IGN,
function address)
set-user-ID mode bit
set-group-ID mode bit
process group ID
tty group ID (see exit(S) and signal(S))
current working directory
root directory
file mode creation mask (see umask(S))
file size limit (see ulimit(S))
The child process differs from the parent process in the
following ways:
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 file
descriptors. Each of the child's file descriptors
shares a common file pointer with the corresponding
file descriptor of the parent.
All semadj values are cleared (see semop(S)).
The child process' utime, stime, cutime, and cstime are
set to 0; see times(S).
Page 1 (printed 8/7/87)
FORK(S) XENIX System V FORK(S)
The time left on the parent's alarm clock is not passed
on to the child.
fork returns a value of 0 to the child process.
fork returns the process ID of the child process to the
parent process.
fork will fail and no child process will be created if one
or more of the following are true:
The system-imposed limit on the total number of
processes under execution would be exceeded. [EAGAIN]
The system-imposed limit on the total number of
processes under execution by a single user would be
exceeded. [EAGAIN]
Not enough memory is available to create the forked
image. [ENOMEM]
Return Value
Upon successful completion, fork returns a value of 0 to the
child process and returns the process ID of the child
process to the parent process. Otherwise, a value of -1 is
returned to the parent process, no child process is created,
and errno is set to indicate the error.
See Also
exec(S), sdget(S), semop(S), shmop(S), wait(S)
Page 2 (printed 8/7/87)