xref: /dflybsd-src/lib/libc/gen/posix_spawn.3 (revision c9c6988b3417c76f002af80950e0b3264917d3b1)
1c4dd129bSPeter Avalos.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
2c4dd129bSPeter Avalos.\" All rights reserved.
3c4dd129bSPeter Avalos.\"
4c4dd129bSPeter Avalos.\" Redistribution and use in source and binary forms, with or without
5c4dd129bSPeter Avalos.\" modification, are permitted provided that the following conditions
6c4dd129bSPeter Avalos.\" are met:
7c4dd129bSPeter Avalos.\" 1. Redistributions of source code must retain the above copyright
8c4dd129bSPeter Avalos.\"    notice, this list of conditions and the following disclaimer.
9c4dd129bSPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright
10c4dd129bSPeter Avalos.\"    notice, this list of conditions and the following disclaimer in the
11c4dd129bSPeter Avalos.\"    documentation and/or other materials provided with the distribution.
12c4dd129bSPeter Avalos.\"
13c4dd129bSPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14c4dd129bSPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15c4dd129bSPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16c4dd129bSPeter Avalos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17c4dd129bSPeter Avalos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18c4dd129bSPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19c4dd129bSPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20c4dd129bSPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21c4dd129bSPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22c4dd129bSPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23c4dd129bSPeter Avalos.\" SUCH DAMAGE.
24c4dd129bSPeter Avalos.\"
25c4dd129bSPeter Avalos.\" Portions of this text are reprinted and reproduced in electronic form
26c4dd129bSPeter Avalos.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
27c4dd129bSPeter Avalos.\" Portable Operating System Interface (POSIX), The Open Group Base
28c4dd129bSPeter Avalos.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
29c4dd129bSPeter Avalos.\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
30c4dd129bSPeter Avalos.\" event of any discrepancy between this version and the original IEEE and
31c4dd129bSPeter Avalos.\" The Open Group Standard, the original IEEE and The Open Group Standard is
32c4dd129bSPeter Avalos.\" the referee document.  The original Standard can be obtained online at
33c4dd129bSPeter Avalos.\"	http://www.opengroup.org/unix/online.html.
34c4dd129bSPeter Avalos.\"
35c4dd129bSPeter Avalos.\" $FreeBSD: src/lib/libc/gen/posix_spawn.3,v 1.2 2008/07/28 09:36:56 ed Exp $
36c4dd129bSPeter Avalos.\"
37ee79eb2cSSascha Wildner.Dd April 7, 2009
38c4dd129bSPeter Avalos.Dt POSIX_SPAWN 3
39c4dd129bSPeter Avalos.Os
40c4dd129bSPeter Avalos.Sh NAME
41c4dd129bSPeter Avalos.Nm posix_spawn ,
42c4dd129bSPeter Avalos.Nm posix_spawnp
43c4dd129bSPeter Avalos.Nd "spawn a process"
44c4dd129bSPeter Avalos.Sh LIBRARY
45c4dd129bSPeter Avalos.Lb libc
46c4dd129bSPeter Avalos.Sh SYNOPSIS
47c4dd129bSPeter Avalos.In spawn.h
48c4dd129bSPeter Avalos.Ft int
49c4dd129bSPeter Avalos.Fn posix_spawn "pid_t *restrict pid" "const char *restrict path" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]"
50c4dd129bSPeter Avalos.Ft int
51c4dd129bSPeter Avalos.Fn posix_spawnp "pid_t *restrict pid" "const char *restrict file" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]"
52c4dd129bSPeter Avalos.Sh DESCRIPTION
53c4dd129bSPeter AvalosThe
54c4dd129bSPeter Avalos.Fn posix_spawn
55c4dd129bSPeter Avalosand
56c4dd129bSPeter Avalos.Fn posix_spawnp
57c4dd129bSPeter Avalosfunctions create a new process (child process) from the specified
58c4dd129bSPeter Avalosprocess image.
59c4dd129bSPeter AvalosThe new process image is constructed from a regular executable
60c4dd129bSPeter Avalosfile called the new process image file.
61c4dd129bSPeter Avalos.Pp
62c4dd129bSPeter AvalosWhen a C program is executed as the result of this call, it is
63c4dd129bSPeter Avalosentered as a C-language function call as follows:
64c4dd129bSPeter Avalos.Bd -literal -offset indent
65c4dd129bSPeter Avalosint main(int argc, char *argv[]);
66c4dd129bSPeter Avalos.Ed
67c4dd129bSPeter Avalos.Pp
68c4dd129bSPeter Avaloswhere
69c4dd129bSPeter Avalos.Fa argc
70c4dd129bSPeter Avalosis the argument count and
71c4dd129bSPeter Avalos.Fa argv
72c4dd129bSPeter Avalosis an array of character pointers to the arguments themselves.
73c4dd129bSPeter AvalosIn addition, the variable:
74c4dd129bSPeter Avalos.Bd -literal -offset indent
75c4dd129bSPeter Avalosextern char **environ;
76c4dd129bSPeter Avalos.Ed
77c4dd129bSPeter Avalos.Pp
78c4dd129bSPeter Avalospoints to an array of character pointers to
79c4dd129bSPeter Avalosthe environment strings.
80c4dd129bSPeter Avalos.Pp
81c4dd129bSPeter AvalosThe argument
82c4dd129bSPeter Avalos.Fa argv
83c4dd129bSPeter Avalosis an array of character pointers to null-terminated
84c4dd129bSPeter Avalosstrings.
85c4dd129bSPeter AvalosThe last member of this array is a null pointer and is not counted
86c4dd129bSPeter Avalosin
87c4dd129bSPeter Avalos.Fa argc .
88c4dd129bSPeter AvalosThese strings constitute the argument list available to the new process
89c4dd129bSPeter Avalosimage.
90c4dd129bSPeter AvalosThe value in
91c4dd129bSPeter Avalos.Fa argv Ns [0]
92c4dd129bSPeter Avalosshould point to
93c4dd129bSPeter Avalosa filename that is associated with the process image being started by
94c4dd129bSPeter Avalosthe
95c4dd129bSPeter Avalos.Fn posix_spawn
96c4dd129bSPeter Avalosor
97c4dd129bSPeter Avalos.Fn posix_spawnp
98c4dd129bSPeter Avalosfunction.
99c4dd129bSPeter Avalos.Pp
100c4dd129bSPeter AvalosThe argument
101c4dd129bSPeter Avalos.Fa envp
102c4dd129bSPeter Avalosis an array of character pointers to null-terminated strings.
103c4dd129bSPeter AvalosThese strings constitute the environment for the new process image.
104c4dd129bSPeter AvalosThe environment array is terminated by a null pointer.
105c4dd129bSPeter Avalos.Pp
106c4dd129bSPeter AvalosThe
107c4dd129bSPeter Avalos.Fa path
108c4dd129bSPeter Avalosargument to
109c4dd129bSPeter Avalos.Fn posix_spawn
110c4dd129bSPeter Avalosis a pathname that identifies the new process image file to execute.
111c4dd129bSPeter Avalos.Pp
112c4dd129bSPeter AvalosThe
113c4dd129bSPeter Avalos.Fa file
114c4dd129bSPeter Avalosparameter to
115c4dd129bSPeter Avalos.Fn posix_spawnp
116c4dd129bSPeter Avalosis used to construct a pathname that identifies the new process
117c4dd129bSPeter Avalosimage file.
118c4dd129bSPeter AvalosIf the file parameter contains a slash character, the file parameter
119c4dd129bSPeter Avalosis used as the pathname for the new process image file.
120c4dd129bSPeter AvalosOtherwise, the path prefix for this file is obtained by a search
121c4dd129bSPeter Avalosof the directories passed as the environment variable
122c4dd129bSPeter Avalos.Dq Ev PATH .
123c4dd129bSPeter AvalosIf this variable is not specified,
124c4dd129bSPeter Avalosthe default path is set according to the
125c4dd129bSPeter Avalos.Dv _PATH_DEFPATH
126c4dd129bSPeter Avalosdefinition in
127c4dd129bSPeter Avalos.In paths.h ,
128c4dd129bSPeter Avaloswhich is set to
129c4dd129bSPeter Avalos.Dq Ev /usr/bin:/bin .
130c4dd129bSPeter Avalos.Pp
131c4dd129bSPeter AvalosIf
132c4dd129bSPeter Avalos.Fa file_actions
133c4dd129bSPeter Avalosis a null pointer, then file descriptors open in the
134c4dd129bSPeter Avaloscalling process remain open in the child process, except for those
135c4dd129bSPeter Avaloswhose close-on-exec flag
136c4dd129bSPeter Avalos.Dv FD_CLOEXEC
137c4dd129bSPeter Avalosis set (see
138c4dd129bSPeter Avalos.Fn fcntl ) .
139c4dd129bSPeter AvalosFor those
140c4dd129bSPeter Avalosfile descriptors that remain open, all attributes of the corresponding
141c4dd129bSPeter Avalosopen file descriptions, including file locks (see
142c4dd129bSPeter Avalos.Fn fcntl ) ,
143c4dd129bSPeter Avalosremain unchanged.
144c4dd129bSPeter Avalos.Pp
145c4dd129bSPeter AvalosIf
146c4dd129bSPeter Avalos.Fa file_actions
147c4dd129bSPeter Avalosis not NULL, then the file descriptors open in the child process are
148c4dd129bSPeter Avalosthose open in the calling process as modified by the spawn file
149c4dd129bSPeter Avalosactions object pointed to by
150c4dd129bSPeter Avalos.Fa file_actions
151c4dd129bSPeter Avalosand the
152c4dd129bSPeter Avalos.Dv FD_CLOEXEC
153c4dd129bSPeter Avalosflag of each remaining open file descriptor after the spawn file actions
154c4dd129bSPeter Avaloshave been processed.
155c4dd129bSPeter AvalosThe effective order of processing the spawn file actions are:
156c4dd129bSPeter Avalos.Bl -enum
157c4dd129bSPeter Avalos.It
158c4dd129bSPeter AvalosThe set of open file descriptors for the child process initially
159c4dd129bSPeter Avalosare the same set as is open for the calling process.
160c4dd129bSPeter AvalosAll attributes of the corresponding open file descriptions, including
161c4dd129bSPeter Avalosfile locks (see
162c4dd129bSPeter Avalos.Fn fcntl ) ,
163c4dd129bSPeter Avalosremain unchanged.
164c4dd129bSPeter Avalos.It
165c4dd129bSPeter AvalosThe signal mask, signal default actions, and the effective user and
166c4dd129bSPeter Avalosgroup IDs for the child process are changed as specified in the
167c4dd129bSPeter Avalosattributes object referenced by
168c4dd129bSPeter Avalos.Fa attrp .
169c4dd129bSPeter Avalos.It
170c4dd129bSPeter AvalosThe file actions specified by the spawn file actions object are
171c4dd129bSPeter Avalosperformed in the order in which they were added to the spawn file
172c4dd129bSPeter Avalosactions object.
173c4dd129bSPeter Avalos.It
174c4dd129bSPeter AvalosAny file descriptor that has its
175c4dd129bSPeter Avalos.Dv FD_CLOEXEC
176c4dd129bSPeter Avalosflag set (see
177c4dd129bSPeter Avalos.Fn fcntl )
178c4dd129bSPeter Avalosis closed.
179c4dd129bSPeter Avalos.El
180c4dd129bSPeter Avalos.Pp
181c4dd129bSPeter AvalosThe
182c4dd129bSPeter Avalos.Vt posix_spawnattr_t
183c4dd129bSPeter Avalosspawn attributes object type is defined in
184c4dd129bSPeter Avalos.In spawn.h .
185c4dd129bSPeter AvalosIt contains the attributes defined below.
186c4dd129bSPeter Avalos.Pp
187c4dd129bSPeter AvalosIf the
188c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETPGROUP
189c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
190c4dd129bSPeter Avalos.Fa attrp ,
191c4dd129bSPeter Avalosand the spawn-pgroup attribute of the same object is non-zero, then the
192c4dd129bSPeter Avaloschild's process group is as specified in the spawn-pgroup
193c4dd129bSPeter Avalosattribute of the object referenced by
194c4dd129bSPeter Avalos.Fa attrp .
195c4dd129bSPeter Avalos.Pp
196c4dd129bSPeter AvalosAs a special case, if the
197c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETPGROUP
198c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
199c4dd129bSPeter Avalos.Fa attrp ,
200c4dd129bSPeter Avalosand the spawn-pgroup attribute of the same object is set to zero, then
201c4dd129bSPeter Avalosthe child is in a new process group with a process group ID equal
202c4dd129bSPeter Avalosto its process ID.
203c4dd129bSPeter Avalos.Pp
204c4dd129bSPeter AvalosIf the
205c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETPGROUP
206c4dd129bSPeter Avalosflag is not set in the spawn-flags attribute of the object referenced by
207c4dd129bSPeter Avalos.Fa attrp ,
208c4dd129bSPeter Avalosthe new child process inherits the parent's process group.
209c4dd129bSPeter Avalos.Pp
210c4dd129bSPeter AvalosIf the
211c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSCHEDPARAM
212c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
213c4dd129bSPeter Avalos.Fa attrp ,
214c4dd129bSPeter Avalosbut
215c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSCHEDULER
216c4dd129bSPeter Avalosis not set, the new process image initially has the scheduling
217c4dd129bSPeter Avalospolicy of the calling process with the scheduling parameters specified
218c4dd129bSPeter Avalosin the spawn-schedparam attribute of the object referenced by
219c4dd129bSPeter Avalos.Fa attrp .
220c4dd129bSPeter Avalos.Pp
221c4dd129bSPeter AvalosIf the
222c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSCHEDULER
223c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
224c4dd129bSPeter Avalos.Fa attrp
225c4dd129bSPeter Avalos(regardless of the setting of the
226c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSCHEDPARAM
227c4dd129bSPeter Avalosflag), the new process image initially has the scheduling policy
228c4dd129bSPeter Avalosspecified in the spawn-schedpolicy attribute of the object referenced by
229c4dd129bSPeter Avalos.Fa attrp
230c4dd129bSPeter Avalosand the scheduling parameters specified in the spawn-schedparam
231c4dd129bSPeter Avalosattribute of the same object.
232c4dd129bSPeter Avalos.Pp
233c4dd129bSPeter AvalosThe
234c4dd129bSPeter Avalos.Dv POSIX_SPAWN_RESETIDS
235c4dd129bSPeter Avalosflag in the spawn-flags attribute of the object referenced by
236c4dd129bSPeter Avalos.Fa attrp
237c4dd129bSPeter Avalosgoverns the effective user ID of the child process.
238c4dd129bSPeter AvalosIf this flag is not set, the child process inherits the parent
239c4dd129bSPeter Avalosprocess' effective user ID.
240c4dd129bSPeter AvalosIf this flag is set, the child process' effective user ID is reset
241c4dd129bSPeter Avalosto the parent's real user ID.
242c4dd129bSPeter AvalosIn either case, if the set-user-ID mode bit of the new process image
243c4dd129bSPeter Avalosfile is set, the effective user ID of the child process becomes
244c4dd129bSPeter Avalosthat file's owner ID before the new process image begins execution.
245c4dd129bSPeter Avalos.Pp
246c4dd129bSPeter AvalosThe
247c4dd129bSPeter Avalos.Dv POSIX_SPAWN_RESETIDS
248c4dd129bSPeter Avalosflag in the spawn-flags attribute of the object referenced by
249c4dd129bSPeter Avalos.Fa attrp
250c4dd129bSPeter Avalosalso governs the effective group ID of the child process.
251c4dd129bSPeter AvalosIf this flag is not set, the child process inherits the parent
252c4dd129bSPeter Avalosprocess' effective group ID.
253c4dd129bSPeter AvalosIf this flag is set, the child process' effective group ID is
254c4dd129bSPeter Avalosreset to the parent's real group ID.
255c4dd129bSPeter AvalosIn either case, if the set-group-ID mode bit of the new process image
256c4dd129bSPeter Avalosfile is set, the effective group ID of the child process becomes
257c4dd129bSPeter Avalosthat file's group ID before the new process image begins execution.
258c4dd129bSPeter Avalos.Pp
259c4dd129bSPeter AvalosIf the
260c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSIGMASK
261c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
262c4dd129bSPeter Avalos.Fa attrp ,
263c4dd129bSPeter Avalosthe child process initially has the signal mask specified in the
264c4dd129bSPeter Avalosspawn-sigmask attribute of the object referenced by
265c4dd129bSPeter Avalos.Fa attrp .
266c4dd129bSPeter Avalos.Pp
267c4dd129bSPeter AvalosIf the
268c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSIGDEF
269c4dd129bSPeter Avalosflag is set in the spawn-flags attribute of the object referenced by
270c4dd129bSPeter Avalos.Fa attrp ,
271c4dd129bSPeter Avalosthe signals specified in the spawn-sigdefault attribute of the same
272c4dd129bSPeter Avalosobject is set to their default actions in the child process.
273c4dd129bSPeter AvalosSignals set to the default action in the parent process is set to
274c4dd129bSPeter Avalosthe default action in the child process.
275c4dd129bSPeter Avalos.Pp
276c4dd129bSPeter AvalosSignals set to be caught by the calling process is set to the
277c4dd129bSPeter Avalosdefault action in the child process.
278c4dd129bSPeter Avalos.Pp
279c4dd129bSPeter AvalosSignals set to be ignored by the calling process image is set to
280c4dd129bSPeter Avalosbe ignored by the child process, unless otherwise specified by the
281c4dd129bSPeter Avalos.Dv POSIX_SPAWN_SETSIGDEF
282c4dd129bSPeter Avalosflag being set in the spawn-flags attribute of the object referenced by
283c4dd129bSPeter Avalos.Fa attrp
284c4dd129bSPeter Avalosand the signals being indicated in the spawn-sigdefault attribute
285c4dd129bSPeter Avalosof the object referenced by
286c4dd129bSPeter Avalos.Fa attrp .
287c4dd129bSPeter Avalos.Pp
288c4dd129bSPeter AvalosIf the value of the
289c4dd129bSPeter Avalos.Fa attrp
290c4dd129bSPeter Avalospointer is NULL, then the default values are used.
291c4dd129bSPeter Avalos.Pp
292c4dd129bSPeter AvalosAll process attributes, other than those influenced by the attributes
293c4dd129bSPeter Avalosset in the object referenced by
294c4dd129bSPeter Avalos.Fa attrp
295c4dd129bSPeter Avalosas specified above or by the file descriptor manipulations specified in
296c4dd129bSPeter Avalos.Fa file_actions ,
297c4dd129bSPeter Avalosappear in the new process image as though
298c4dd129bSPeter Avalos.Fn vfork
299c4dd129bSPeter Avaloshad been called to create a child process and then
300c4dd129bSPeter Avalos.Fn execve
301c4dd129bSPeter Avaloshad been called by the child process to execute the new process image.
302c4dd129bSPeter Avalos.Pp
3034041d919SSascha WildnerThe implementation uses
3044041d919SSascha Wildner.Fn vfork ,
3054041d919SSascha Wildnerthus the fork handlers are not run when
306c4dd129bSPeter Avalos.Fn posix_spawn
307c4dd129bSPeter Avalosor
308c4dd129bSPeter Avalos.Fn posix_spawnp
309c4dd129bSPeter Avalosis called.
310c4dd129bSPeter Avalos.Sh RETURN VALUES
311c4dd129bSPeter AvalosUpon successful completion,
312c4dd129bSPeter Avalos.Fn posix_spawn
313c4dd129bSPeter Avalosand
314c4dd129bSPeter Avalos.Fn posix_spawnp
315c4dd129bSPeter Avalosreturn the process ID of the child process to the parent process,
316c4dd129bSPeter Avalosin the variable pointed to by a non-NULL
317c4dd129bSPeter Avalos.Fa pid
318c4dd129bSPeter Avalosargument, and return zero as the function return value.
319c4dd129bSPeter AvalosOtherwise, no child process is created, no value is stored into
320c4dd129bSPeter Avalosthe variable pointed to by
321c4dd129bSPeter Avalos.Fa pid ,
322c4dd129bSPeter Avalosand an error number is returned as the function return value to
323c4dd129bSPeter Avalosindicate the error.
324c4dd129bSPeter AvalosIf the
325c4dd129bSPeter Avalos.Fa pid
326c4dd129bSPeter Avalosargument is a null pointer, the process ID of the child is not returned
327c4dd129bSPeter Avalosto the caller.
328c4dd129bSPeter Avalos.Sh ERRORS
329c4dd129bSPeter Avalos.Bl -enum
330c4dd129bSPeter Avalos.It
331c4dd129bSPeter AvalosIf
332c4dd129bSPeter Avalos.Fn posix_spawn
333c4dd129bSPeter Avalosand
334c4dd129bSPeter Avalos.Fn posix_spawnp
335c4dd129bSPeter Avalosfail for any of the reasons that would cause
336c4dd129bSPeter Avalos.Fn vfork
337c4dd129bSPeter Avalosor one of the
338c4dd129bSPeter Avalos.Nm exec
339c4dd129bSPeter Avalosto fail, an error value is returned as described by
340c4dd129bSPeter Avalos.Fn vfork
341c4dd129bSPeter Avalosand
342c4dd129bSPeter Avalos.Nm exec ,
343c4dd129bSPeter Avalosrespectively (or, if the error occurs after the calling process successfully
344c4dd129bSPeter Avalosreturns, the child process exits with exit status 127).
345c4dd129bSPeter Avalos.It
346c4dd129bSPeter AvalosIf
3472192e32eSSascha Wildner.Dv POSIX_SPAWN_SETPGROUP
348c4dd129bSPeter Avalosis set in the spawn-flags attribute of the object referenced by attrp, and
349c4dd129bSPeter Avalos.Fn posix_spawn
350c4dd129bSPeter Avalosor
351c4dd129bSPeter Avalos.Fn posix_spawnp
352c4dd129bSPeter Avalosfails while changing the child's process group, an error value is returned as
353c4dd129bSPeter Avalosdescribed by
354c4dd129bSPeter Avalos.Fn setpgid
355c4dd129bSPeter Avalos(or, if the error occurs after the calling process successfully returns,
356c4dd129bSPeter Avalosthe child process exits with exit status 127).
357c4dd129bSPeter Avalos.It
358c4dd129bSPeter AvalosIf
3592192e32eSSascha Wildner.Dv POSIX_SPAWN_SETSCHEDPARAM
360c4dd129bSPeter Avalosis set and
3612192e32eSSascha Wildner.Dv POSIX_SPAWN_SETSCHEDULER
362c4dd129bSPeter Avalosis not set in the spawn-flags attribute of the object referenced by attrp, then
363c4dd129bSPeter Avalosif
364c4dd129bSPeter Avalos.Fn posix_spawn
365c4dd129bSPeter Avalosor
366c4dd129bSPeter Avalos.Fn posix_spawnp
367c4dd129bSPeter Avalosfails for any of the reasons that would cause
368c4dd129bSPeter Avalos.Fn sched_setparam
369c4dd129bSPeter Avalosto fail, an error value is returned as described by
370c4dd129bSPeter Avalos.Fn sched_setparam
371c4dd129bSPeter Avalos(or, if the error occurs after the calling process successfully returns, the
372c4dd129bSPeter Avaloschild process exits with exit status 127).
373c4dd129bSPeter Avalos.It
374c4dd129bSPeter AvalosIf
3752192e32eSSascha Wildner.Dv POSIX_SPAWN_SETSCHEDULER
376c4dd129bSPeter Avalosis set in the spawn-flags attribute of the object referenced by attrp, and if
377c4dd129bSPeter Avalos.Fn posix_spawn
378c4dd129bSPeter Avalosor
379c4dd129bSPeter Avalos.Fn posix_spawnp
380c4dd129bSPeter Avalosfails for any of the reasons that would cause
381c4dd129bSPeter Avalos.Fn sched_setscheduler
382c4dd129bSPeter Avalosto fail, an error value is returned as described by
383c4dd129bSPeter Avalos.Fn sched_setscheduler
384c4dd129bSPeter Avalos(or, if the error occurs after the calling process successfully returns,
385c4dd129bSPeter Avalosthe child process exits with exit status 127).
386c4dd129bSPeter Avalos.It
387c4dd129bSPeter AvalosIf the
388c4dd129bSPeter Avalos.Fa file_actions
389c4dd129bSPeter Avalosargument is not NULL, and specifies any close, dup2, or open actions to be
390c4dd129bSPeter Avalosperformed, and if
391c4dd129bSPeter Avalos.Fn posix_spawn
392c4dd129bSPeter Avalosor
393c4dd129bSPeter Avalos.Fn posix_spawnp
394c4dd129bSPeter Avalosfails for any of the reasons that would cause
395c4dd129bSPeter Avalos.Fn close ,
396c4dd129bSPeter Avalos.Fn dup2 ,
397c4dd129bSPeter Avalosor
398c4dd129bSPeter Avalos.Fn open
399c4dd129bSPeter Avalosto fail, an error value is returned as described by
400c4dd129bSPeter Avalos.Fn close ,
401c4dd129bSPeter Avalos.Fn dup2 ,
402c4dd129bSPeter Avalosand
403c4dd129bSPeter Avalos.Fn open ,
404c4dd129bSPeter Avalosrespectively (or, if the error occurs after the calling process successfully
405c4dd129bSPeter Avalosreturns, the child process exits with exit status 127). An open file action
406c4dd129bSPeter Avalosmay, by itself, result in any of the errors described by
407c4dd129bSPeter Avalos.Fn close
408c4dd129bSPeter Avalosor
409c4dd129bSPeter Avalos.Fn dup2 ,
410c4dd129bSPeter Avalosin addition to those described by
411c4dd129bSPeter Avalos.Fn open .
412c4dd129bSPeter Avalos.El
413c4dd129bSPeter Avalos.Sh SEE ALSO
414c4dd129bSPeter Avalos.Xr close 2 ,
415c4dd129bSPeter Avalos.Xr dup2 2 ,
416c4dd129bSPeter Avalos.Xr execve 2 ,
417c4dd129bSPeter Avalos.Xr fcntl 2 ,
418c4dd129bSPeter Avalos.Xr open 2 ,
4192e7bdddeSSascha Wildner.Xr sched_setparam 2 ,
4202e7bdddeSSascha Wildner.Xr sched_setscheduler 2 ,
4212e7bdddeSSascha Wildner.Xr setpgid 2 ,
4222e7bdddeSSascha Wildner.Xr vfork 2 ,
423c4dd129bSPeter Avalos.Xr posix_spawn_file_actions_addclose 3 ,
424c4dd129bSPeter Avalos.Xr posix_spawn_file_actions_adddup2 3 ,
425c4dd129bSPeter Avalos.Xr posix_spawn_file_actions_addopen 3 ,
426c4dd129bSPeter Avalos.Xr posix_spawn_file_actions_destroy 3 ,
427c4dd129bSPeter Avalos.Xr posix_spawn_file_actions_init 3 ,
428c4dd129bSPeter Avalos.Xr posix_spawnattr_destroy 3 ,
429c4dd129bSPeter Avalos.Xr posix_spawnattr_getflags 3 ,
430c4dd129bSPeter Avalos.Xr posix_spawnattr_getpgroup 3 ,
431c4dd129bSPeter Avalos.Xr posix_spawnattr_getschedparam 3 ,
432c4dd129bSPeter Avalos.Xr posix_spawnattr_getschedpolicy 3 ,
433c4dd129bSPeter Avalos.Xr posix_spawnattr_getsigdefault 3 ,
434c4dd129bSPeter Avalos.Xr posix_spawnattr_getsigmask 3 ,
435c4dd129bSPeter Avalos.Xr posix_spawnattr_init 3 ,
436c4dd129bSPeter Avalos.Xr posix_spawnattr_setflags 3 ,
437c4dd129bSPeter Avalos.Xr posix_spawnattr_setpgroup 3 ,
438c4dd129bSPeter Avalos.Xr posix_spawnattr_setschedparam 3 ,
439c4dd129bSPeter Avalos.Xr posix_spawnattr_setschedpolicy 3 ,
440c4dd129bSPeter Avalos.Xr posix_spawnattr_setsigdefault 3 ,
4412e7bdddeSSascha Wildner.Xr posix_spawnattr_setsigmask 3
442c4dd129bSPeter Avalos.Sh STANDARDS
443c4dd129bSPeter AvalosThe
444c4dd129bSPeter Avalos.Fn posix_spawn
445c4dd129bSPeter Avalosand
446c4dd129bSPeter Avalos.Fn posix_spawnp
447c4dd129bSPeter Avalosfunctions conform to
448c4dd129bSPeter Avalos.St -p1003.1-2001 .
449c4dd129bSPeter Avalos.Sh HISTORY
450c4dd129bSPeter AvalosThe
451c4dd129bSPeter Avalos.Fn posix_spawn
452c4dd129bSPeter Avalosand
453c4dd129bSPeter Avalos.Fn posix_spawnp
454c4dd129bSPeter Avalosfunctions first appeared in
455c4dd129bSPeter Avalos.Fx 8.0 .
456c4dd129bSPeter Avalos.Sh AUTHORS
457*c9c6988bSSascha Wildner.An \&Ed Schouten Aq Mt ed@FreeBSD.org
458