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 $
7 .\" $DragonFly: src/lib/libc/sys/rfork.2,v 1.7 2007/12/08 23:20:29 swildner Exp $
14 .Nd manipulate process resources
22 Forking, vforking or rforking are the only ways new processes are created.
27 selects which resources of the
28 invoking process (parent) are shared
29 by the new process (child) or initialized to
32 the open file descriptor table (which, when shared, permits processes
33 to open and close files for other processes),
36 is the logical OR of some subset of:
37 .Bl -tag -width ".Dv RFLINUXTHPN" -compact -offset indent
39 If set a new process is created; otherwise changes affect the
41 The current implementation requires this flag to always be set.
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 kernel will force sharing of the entire address space,
59 typically by sharing the hardware page table directly.
61 will thus inherit and share all the segments the parent process owns,
62 whether they are normally shareable or not.
64 not split (both the parent and child return on the same stack) and thus
68 flag may not generally be called directly from high level
69 languages including C.
72 A helper function is provided to assist with this problem and will cause
73 the new process to run on the provided stack.
78 If set, the kernel will force sharing the sigacts structure between the
81 If set, the kernel will return
83 instead of SIGCHILD upon thread exit for the child.
84 This is intended to mimic certain Linux clone behaviour.
87 File descriptors in a shared file descriptor table are kept
88 open until either they are explicitly closed
89 or all processes sharing the table exit.
94 value returned in the parent process
96 of the child process; the value returned in the child is zero.
99 the return value is zero.
100 Process id's range from 1 to the maximum integer
104 will sleep, if necessary, until required process resources are available.
107 can be implemented as a call to
108 .Fn rfork "RFFDG | RFPROC"
109 but isn't for backwards compatibility.
111 Upon successful completion,
114 of 0 to the child process and returns the process ID of the child
115 process to the parent process.
116 Otherwise, a value of -1 is returned to the parent process, no
117 child process is created, and the global variable
119 is set to indicate the error.
122 will fail and no child process will be created if:
125 The system-imposed limit on the total
126 number of processes under execution would be exceeded.
127 The limit is given by the
131 (The limit is actually ten less than this
132 except for the super user).
134 The user is not the super user, and
135 the system-imposed limit
136 on the total number of
137 processes under execution by a single user would be exceeded.
138 The limit is given by the
141 .Dv KERN_MAXPROCPERUID .
143 The user is not the super user, and
144 the soft resource limit corresponding to the resource parameter
146 would be exceeded (see
151 flag was not specified.
157 flags were specified.
159 There is insufficient swap space for the new process.
171 function call first appeared in Plan 9.
174 does not yet implement a native
176 library call, and the current pthreads implementation does not use
180 A native port of the linux threads library,
181 .Pa /usr/ports/devel/linuxthreads ,
188 library call can often be used instead of