2 .\" This manual page is taken directly from Plan 9, and modified to
3 .\" describe the actual BSD implementation. Permission for
4 .\" use of this page comes from Rob Pike <rob@plan9.att.com>.
6 .\" $FreeBSD: src/lib/libc/sys/rfork.2,v 1.11.2.11 2002/07/30 19:04:25 silby Exp $
13 .Nd manipulate process resources
21 Forking, vforking or rforking are the only ways new processes are created.
26 selects which resources of the
27 invoking process (parent) are shared
28 by the new process (child) or initialized to
31 the open file descriptor table (which, when shared, permits processes
32 to open and close files for other processes),
35 is the logical OR of some subset of:
36 .Bl -tag -width ".Dv RFLINUXTHPN" -compact -offset indent
38 If set a new process is created; otherwise changes affect the
40 The current implementation requires this flag to always be set.
42 If set, the child process will be dissociated from the parent.
44 exit the child will not leave a status for the parent to collect.
48 If set, the invoker's file descriptor table (see
50 is copied; otherwise the two processes share a
53 If set, the new process starts with a clean file descriptor table.
54 Is mutually exclusive with
57 If set, the kernel will force sharing of the entire address space,
58 typically by sharing the hardware page table directly.
60 will thus inherit and share all the segments the parent process owns,
61 whether they are normally shareable or not.
63 not split (both the parent and child return on the same stack) and thus
67 flag may not generally be called directly from high level
68 languages including C.
71 A helper function is provided to assist with this problem and will cause
72 the new process to run on the provided stack.
77 If set, the kernel will force sharing the sigacts structure between the
80 If set, the kernel will return
82 instead of SIGCHILD upon thread exit for the child.
83 This is intended to mimic certain Linux clone behaviour.
86 File descriptors in a shared file descriptor table are kept
87 open until either they are explicitly closed
88 or all processes sharing the table exit.
93 value returned in the parent process
95 of the child process; the value returned in the child is zero.
98 the return value is zero.
99 Process id's range from 1 to the maximum integer
103 will sleep, if necessary, until required process resources are available.
106 can be implemented as a call to
107 .Fn rfork "RFFDG | RFPROC"
108 but isn't for backwards compatibility.
110 Upon successful completion,
113 of 0 to the child process and returns the process ID of the child
114 process to the parent process.
115 Otherwise, a value of -1 is returned to the parent process, no
116 child process is created, and the global variable
118 is set to indicate the error.
121 will fail and no child process will be created if:
124 The system-imposed limit on the total
125 number of processes under execution would be exceeded.
126 The limit is given by the
130 (The limit is actually ten less than this
131 except for the super user).
133 The user is not the super user, and
134 the system-imposed limit
135 on the total number of
136 processes under execution by a single user would be exceeded.
137 The limit is given by the
140 .Dv KERN_MAXPROCPERUID .
142 The user is not the super user, and
143 the soft resource limit corresponding to the resource parameter
145 would be exceeded (see
150 flag was not specified.
156 flags were specified.
158 There is insufficient swap space for the new process.
170 function call first appeared in Plan 9.