2 .\" This manual page is taken directly from Plan9, and modified to
3 .\" describe the actual BSD implementation. Permission for
4 .\" use of this page comes from Rob Pike <rob@plan9.att.com>.
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),
37 is the logical OR of some subset of:
38 .Bl -tag -width ".Dv RFLINUXTHPN"
40 If set a new process is created; otherwise changes affect the
43 If set, the child process will be dissociated from the parent.
45 exit the child will not leave a status for the parent to collect.
49 If set, the invoker's file descriptor table (see
51 is copied; otherwise the two processes share a
54 If set, the new process starts with a clean file descriptor table.
55 Is mutually exclusive with
58 If set, the new process shares file descriptor to process leaders table
60 Only applies when neither
66 If set, the kernel will force sharing of the entire address space,
67 typically by sharing the hardware page table directly.
69 will thus inherit and share all the segments the parent process owns,
70 whether they are normally shareable or not.
72 not split (both the parent and child return on the same stack) and thus
74 with the RFMEM flag may not generally be called directly from high level
75 languages including C.
78 A helper function is provided to assist with this problem and will cause
79 the new process to run on the provided stack.
83 Note that a lot of code will not run correctly in such an environment.
85 If set, the kernel will force sharing the sigacts structure between the
88 If set, the kernel will deliver a specified signal to the parent
89 upon the child exit, instead of default SIGCHLD.
92 is specified by oring the
93 .Dv RFTSIGFLAGS(signum)
96 Specifying signal number 0 disables signal delivery upon the child exit.
98 If set, the kernel will deliver SIGUSR1 instead of SIGCHLD upon thread
100 This is intended to mimic certain Linux clone behaviour.
103 File descriptors in a shared file descriptor table are kept
104 open until either they are explicitly closed
105 or all processes sharing the table exit.
110 value returned in the parent process
112 of the child process; the value returned in the child is zero.
115 the return value is zero.
116 Process id's range from 1 to the maximum integer
122 will sleep, if necessary, until required process resources are available.
127 can be implemented as a call to
128 .Fn rfork "RFFDG | RFPROC"
129 but is not for backwards compatibility.
131 Upon successful completion,
134 of 0 to the child process and returns the process ID of the child
135 process to the parent process.
136 Otherwise, a value of -1 is returned
137 to the parent process, no child process is created, and the global
140 is set to indicate the error.
145 will fail and no child process will be created if:
148 The system-imposed limit on the total
149 number of processes under execution would be exceeded.
150 The limit is given by the
154 (The limit is actually ten less than this
155 except for the super user).
157 The user is not the super user, and
158 the system-imposed limit
159 on the total number of
160 processes under execution by a single user would be exceeded.
161 The limit is given by the
164 .Dv KERN_MAXPROCPERUID .
166 The user is not the super user, and
167 the soft resource limit corresponding to the
171 would be exceeded (see
174 Both the RFFDG and the RFCFDG flags were specified.
176 Any flags not listed above were specified.
178 An invalid signal number was specified.
180 There is insufficient swap space for the new process.
187 .Xr pthread_create 3 ,
192 function first appeared in Plan9.