fork(2)
_________________________________________________________________
fork System Call
Create a new process.
_________________________________________________________________
SYNTAX
int fork ()
PARAMETERS
None.
DESCRIPTION
Fork creates a new process with its own address space that is
initialized to the contents of the calling process's address
space at the time the "fork" call is made. The new process is
entered into the process tree as a child of the calling process.
The following attributes in the new process are set to the values
the parent process had at the time of the fork call:
Environment
Signal handling settings
(i.e., SIG_DFL, SIG_IGN, function address)
Real- and effective-user-id
Real- and effective-group-id
Tty group id
Group list
Profiling on/off status
Nice value (see nice)
All attached shared memory segments (see shmop)
Process group ID
Current working directory
Root directory
File mode creation mask (see umask)
Resources utilization limits (see ulimit, setrlimit)
Controlling terminal device
Close on exec flag
The child process differs from the parent process in the
following ways:
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
fork(2)
* The child process has a unique process ID.
* The child process has a different parent process ID (the
process ID of its parent).
* The child process has its own copy of each of the parent's
object descriptors, with the close-on-exec flag in each set
to the value from the corresponding object descriptor in the
parent. Each of the child's object descriptors shares a
common object pointer with the corresponding object
descriptor of the parent.
* File locks set by the parent are not inherited by the child.
* The child process's pending signal vector is cleared.
* All semaphore adjustment values are cleared (see semop).
* Process locks, text locks and data locks are not inherited
by the child (see plock).
* The child process's current resources consumed and
cumulative resources consumed by its children are set to
zero. This includes the child's utime, stime, cutime, and
cstime. (see setrlimit)
* The value of ITIMER_REAL (used by alarm and setitimer) is
set to 0 so that SIGALRMs are disabled. ITIMER_VIRTUAL and
ITIMER_PROF (used by setitimer) are also set to 0 (ie. all
pending alarms are cleared in the child).
* The child process is not traced, regardless of whether the
parent is traced.
ACCESS CONTROL
If the new process would cause the system-imposed limit on the
total number of processes in the system to be reached, an error
is returned and the new process is not created, unless the
calling process has an effective-user-id of 0. In other words,
only the superuser is allowed to create a process that causes the
limit to be reached.
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
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
fork(2)
indicate the error.
EXCEPTIONS
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.
ENOMEM The process requires more space than the system is
able to supply.
SEE ALSO
The related system calls: exec(2), vfork(2), nice(2), plock(2),
ptrace(2), semop(2), shmop(2), signal(2), sigset(2), times(2),
ulimit(2), umask(2), wait(2).
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)