1
0
Files
irix-657m-src/eoe/man/man2/fork.2
2022-09-29 17:59:04 +03:00

248 lines
5.8 KiB
Groff

'\"macro stdmacro
.if n .pH g2.fork @(#)fork 41.5 of 5/26/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} fork 2 "" "\&"
.if \nX=1 .ds x} fork 2 ""
.if \nX=2 .ds x} fork 2 "" "\&"
.if \nX=3 .ds x} fork "" "" "\&"
.TH \*(x}
.SH NAME
\f4fork\fP, \f4vfork\fP \- create a new process
.Op c p a
.SH C SYNOPSIS
\f4#include <sys/types.h>\fP
.br
\f4#include <unistd.h>\fP
.PP
.B "pid_t fork (void);"
.PP
\f4#if _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED==1\f1
.br
.B "pid_t vfork (void);"
.br
\f4#endif\f1
.sp
Only when in the X/Open XPG4 Extended Unix name space are \f4vfork\fP and
\f4fork\fP exactly the same in this system and any reference to
\f4fork\fP in this document also applies to \f4vfork\fP. It should also be
noted that this \f4vfork\fP is \f4NOT\fP and \f4DOES NOT\fP have the same
semantics as the original BSD \f4vfork\fP.
.Op
.Op f
.SH FORTRAN SYNOPSIS
.B "integer function fork()"
.Op
.SH DESCRIPTION
\f4fork\fP
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:
.PP
.PD 0
.RS
.PP
real user \s-1ID\s+1, real group \s-1ID\s+1, effective user \s-1ID\s+1, effective group \s-1ID\s+1
.PP
environment
.PP
close-on-exec flag [see
\f4exec\fP(2)]
.PP
signal handling settings (i.e.,
\f4SIG_DFL\f1, \f4SIG_IGN\f1, \f4SIG_HOLD\f1,
function address)
.PP
supplementary group IDs
.PP
set-user-\s-1ID\s+1 mode bit
.PP
set-group-\s-1ID\s+1 mode bit
.PP
profiling on/off/mode status [see \f4sprofil\fP(2)]
.PP
debugger tracing status [see \f4proc\fP(4)]
.PP
nice value [see
\f4nice\fP(2)]
.PP
scheduler class [see \f4proc\fP(4) and \f4schedctl\fP(2)]
.PP
all attached shared memory segments [see
\f4shmop\fP(2)]
.PP
all mapped files [see \f4mmap\f1(2)]
.PP
non-degrading priority [see \f4schedctl\f1(2)]
.PP
process group
.SM ID
.PP
session
.SM ID
[see \f4exit\fP(2)]
.PP
current working directory
.PP
root directory
.PP
file mode creation mask [see
\f4umask\fP(2)]
.PP
resource limits [see
\f4getrlimit\fP(2)]
.PP
controlling terminal
.PP
all machine register state including floating point
.br
.ti +5
control register(s)
.\".PP
.\"working and maximum privilege sets
.\".PP
.\"Mandatory Access Control level
.RE
.PD
.PP
The child process differs from the parent process in the following ways:
.IP
The child process has a unique process
.SM ID\*S
which does not match any active process group
.SM ID\*S.
.IP
The child process has a different parent process
.SM ID
(i.e., the
process
.SM ID
of the parent process).
.IP
The child process has its own copy of the parent's file descriptors and
directory streams.
Each of the child's file descriptors shares a common file pointer with the
corresponding file descriptor of the parent.
.IP
File locks previously set by the parent are not inherited by the child [see
\f4fcntl\fP(2)].
.IP
All semadj values are cleared [see
\f4semop\fP(2)].
.IP
Process locks, text locks and data locks are not inherited by the child [see
\f4plock\fP(2)].
.IP
The set of signals pending to the parent is not inherited by the child.
.IP
Page locks are not inherited [see \f4mpin\f1(2)].
.IP
The child process's
.IR utime , " stime" , " cutime" ,
and
.I cstime\^
are set to 0.
The time left until an alarm clock signal is reset to 0.
.IP
The time left until an itimer signal is reset to 0.
.IP
The child will not inherit the ability to make graphics calls.
The child process may receive a segmentation fault upon attempting
to make a graphics call, unless it initializes itself as a
graphics process via \f4winopen\fP() or \f4ginit\fP().
\f2NOTE:\f1 Currently, if the parent is a graphics process, the child's
attempt to become a graphics process will fail.
.IP
The share mask is set to 0 [see \f4sproc\f1(2)].
.PP
If a \f4fork\fP
is performed by a process that is part of a share group [see
\f4sproc\fP(2)])
then the new child process will automatically be added to the parallel
C library I/O arena.
This can result in additional ways that
\f4fork\fP
can fail.
.PP
\f4fork\fP
will fail and no child process will be created if one or more of the
following are true:
.sp
.TP 12
\s-1\%[EAGAIN]\s+1
The system-imposed limit on the total number of processes under execution,
.I {NPROC}
[see
\f4intro\fP(2)],
would be exceeded.
.TP
\s-1\%[EAGAIN]\s+1
The system-imposed limit on the total number of processes under execution
by a single user
.I {CHILD_MAX}
[see
\f4intro\fP(2)],
would be exceeded.
.TP
\s-1\%[EAGAIN]\s+1
Amount of system memory
required is temporarily unavailable.
.PP
When the caller is a member of a share group
in addition to the above errors
\f4fork\fP
will fail and no new process will be created if one or more of the
following are true:
.TP 12
.SM
\%[ENOSPC]
If the total number of share group members plus children exceeds the
maximum number of users specified via
\f4usconfig\fP(3P)
(8 by default).
Any changes via
\f4usconfig\fP(3P)
must be done
BEFORE the first
\f4sproc\fP
is performed.
.TP
.SM
\%[ENOLCK]
There are not enough file locks in the system.
.TP
.I "New process pid # could not join I/O arena:<..>"
if the new process could not properly join the parallel C library I/O
arena.
The new process in this case exits with a \-1.
.SH "SEE ALSO"
exec(2), intro(2), mmap(2), nice(2),
plock(2), ptrace(2),
schedctl(2), semop(2), shmop(2), signal(2),
sigset(2), sigaction(2),
schedctl(2),
sproc(2),
sprofil(2),
times(2), ulimit(2), umask(2), wait(2),
pcreate(3C),
signal(3B), sigvec(3B),
usinit(3P),
usconfig(3P),
proc(4).
.SH DIAGNOSTICS
Upon successful completion,
\f4fork\fP
returns a value of \f40\fP to the child process and returns the process
.SM ID
of the
child process to the parent process.
Otherwise, a value of \f2(pid_t)\-1\fP is
returned to the parent process, no child process is created, and
\f4errno\fP
is set to indicate the error.
.\" @(#)fork.2 6.2 of 9/6/83
.Ee