FORK(2) SysV FORK(2)
NAME
fork - create a new process
SYNOPSIS
int fork ()
DESCRIPTION
fork creates a new process. The new (child) process is an exact copy of
the calling (parent) process. The child process inherits the following
attributes from the parent process:
o Environment
o Close-on-exec flag (see exec(2))
o Signal handling settings (that is, SIG_DFL, SIG_IGN, SIG_HOLD,
function address)
o set-user-ID mode bit
o set-group-ID mode bit
o Profiling on/off status
o nice value (see nice(2))
o All attached shared memory segments (see shmop(2))
o Process group ID
o tty group ID (see exit(2))
o Current working directory
o Root directory
o File mode creation mask (see umask(2))
o File size limit (see ulimit(2))
The child process differs from the parent process in the following ways:
o The child process has a unique process ID.
o The child process has a different parent process ID (that is, the
process ID of the parent process).
o 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.
o All semadj values are cleared (see semop(2)).
o Process locks, text locks, and data locks are not inherited by the
child (see plock(2)).
o The child process' utime, stime, cutime, and cstime are set to 0. The
time left until an alarm clock signal is reset to 0.
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.
[EAGAIN] The system-imposed limit on the total number of processes
under execution by a single user would be exceeded.
[EAGAIN] Total amount of system memory available when reading via raw
I/O is temporarily insufficient.
NOTES
Programs which open streams using Domain/OS calls and then fork() may not
to work as expected. From the mbx calls, for instance, server handles
aren't reference counted. Similar incompatibilities with fork() exist
among the gpr and gpio Domain/OS calls. (Streams opened with the ios
Domain/OS system calls are compatible with fork().)
SEE ALSO
exec(2), nice(2), plock(2), ptrace(2), semop(2), shmop(2), signal(2),
sigset(2), times(2), ulimit(2), umask(2), wait(2).
DIAGNOSTICS
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.