1 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T.
4 .\" Copyright (c) 1980 Regents of the University of California.
5 .\" All rights reserved. The Berkeley software License Agreement
6 .\" specifies the terms and conditions for redistribution.
13 .Nd spawn new process in a virtual memory efficient way
21 .Fn vforkx "int flags"
27 functions create a new process without
28 fully copying the address space of the old process.
29 These functions are useful in instances where the purpose of a
31 operation is to create a new
38 function, the child process borrows the parent's
39 memory and thread of control until a call to
42 .Pq either abnormally or by a call to Xr _exit 2 .
44 made during this time to any part of memory in the child process is reflected
45 in the parent process on return from
49 The parent process is suspended while the child is using its resources.
51 In a multithreaded application,
55 borrow only the thread of control that called
59 in the parent; that is, the child contains only one thread.
64 in multithreaded applications, however, is unsafe due to race
65 conditions that can cause the child process to become deadlocked and
66 consequently block both the child and parent process from execution
73 functions can normally be used the same way as
78 The calling procedure, however, should not return while running in the child's
79 context, since the eventual return from
83 in the parent would be to
84 a stack frame that no longer exists.
87 function should be used
90 if unable to perform an
94 will invoke all functions registered by
96 and will flush and close standard I/O channels, thereby corrupting the parent
97 process's standard I/O data structures.
98 Care must be taken in the child process not to modify any global or local data
99 that affects the behavior of the parent process on return from
103 unless such an effect
110 fork handlers are not run when
120 functions are deprecated.
121 Their sole legitimate use as a prelude to an immediate call to a function from
124 family can be achieved safely by
127 .Xr posix_spawnp 3C .
128 .Ss "Fork Extensions"
133 argument consisting of a
134 bitwise inclusive-OR of zero or more of the following flags, which are defined
138 .Bl -item -compact -offset indent
147 for descriptions of these flags.
155 Upon successful completion,
160 the child process and return the process ID of the child process to the parent
162 Otherwise, \(mi1 is returned to the parent process, no child process is created,
165 is set to indicate the error.
171 functions will fail if:
174 The system-imposed limit on the total number of processes under execution
175 (either system-quality or by a single user) would be exceeded.
176 This limit is determined when the system is generated.
179 There is insufficient swap space for the new process.
184 function will fail if:
191 .Sh INTERFACE STABILITY
195 .Sy Obsolete Standard .
200 .Sy Obsolete Uncommitted .
211 .Xr posix_spawnp 3C ,
216 To avoid a possible deadlock situation, processes that are children in the
225 signals; rather, output or ioctls are allowed and input attempts
230 To forestall parent memory corruption due to race conditions with signal
235 treat signal handlers in the child
236 process in the same manner as the
238 functions: signals set to be
239 caught by the parent process are set to the default action
242 .Pq see Xr signal.h 3HEAD .
243 Any attempt to set a signal
244 handler in the child before
246 to anything other than
250 is disallowed and results in setting the handler to
253 On some systems, the implementation of
258 the parent to inherit register values from the child.
259 This can create problems for certain optimizing compilers if
261 is not included in the source calling
265 is not included in the
271 function is available in the following compilation environments.
284 It was marked obsolete in
291 function is a local extension and not available in any strictly
292 standards-compliant compilation environment.