162187b41SDavid Xu.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 262187b41SDavid Xu.\" All rights reserved. 362187b41SDavid Xu.\" 462187b41SDavid Xu.\" Redistribution and use in source and binary forms, with or without 562187b41SDavid Xu.\" modification, are permitted provided that the following conditions 662187b41SDavid Xu.\" are met: 762187b41SDavid Xu.\" 1. Redistributions of source code must retain the above copyright 862187b41SDavid Xu.\" notice, this list of conditions and the following disclaimer. 962187b41SDavid Xu.\" 2. Redistributions in binary form must reproduce the above copyright 1062187b41SDavid Xu.\" notice, this list of conditions and the following disclaimer in the 1162187b41SDavid Xu.\" documentation and/or other materials provided with the distribution. 1262187b41SDavid Xu.\" 1362187b41SDavid Xu.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1462187b41SDavid Xu.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1562187b41SDavid Xu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1662187b41SDavid Xu.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1762187b41SDavid Xu.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1862187b41SDavid Xu.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1962187b41SDavid Xu.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2062187b41SDavid Xu.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2162187b41SDavid Xu.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2262187b41SDavid Xu.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2362187b41SDavid Xu.\" SUCH DAMAGE. 2462187b41SDavid Xu.\" 2562187b41SDavid Xu.\" Portions of this text are reprinted and reproduced in electronic form 2662187b41SDavid Xu.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- 2762187b41SDavid Xu.\" Portable Operating System Interface (POSIX), The Open Group Base 2862187b41SDavid Xu.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of 2962187b41SDavid Xu.\" Electrical and Electronics Engineers, Inc and The Open Group. In the 3062187b41SDavid Xu.\" event of any discrepancy between this version and the original IEEE and 3162187b41SDavid Xu.\" The Open Group Standard, the original IEEE and The Open Group Standard is 3262187b41SDavid Xu.\" the referee document. The original Standard can be obtained online at 3362187b41SDavid Xu.\" http://www.opengroup.org/unix/online.html. 3462187b41SDavid Xu.\" 3562187b41SDavid Xu.\" $FreeBSD$ 3662187b41SDavid Xu.\" 3743d53dbaSJilles Tjoelker.Dd January 5, 2016 3862187b41SDavid Xu.Dt POSIX_SPAWN 3 3962187b41SDavid Xu.Os 4062187b41SDavid Xu.Sh NAME 4162187b41SDavid Xu.Nm posix_spawn , 4262187b41SDavid Xu.Nm posix_spawnp 4362187b41SDavid Xu.Nd "spawn a process" 4462187b41SDavid Xu.Sh LIBRARY 4562187b41SDavid Xu.Lb libc 4662187b41SDavid Xu.Sh SYNOPSIS 4762187b41SDavid Xu.In spawn.h 4862187b41SDavid Xu.Ft int 49*8ed1e4a5SKonstantin Belousov.Fo posix_spawn 50*8ed1e4a5SKonstantin Belousov.Fa "pid_t *restrict pid" 51*8ed1e4a5SKonstantin Belousov.Fa "const char *restrict path" 52*8ed1e4a5SKonstantin Belousov.Fa "const posix_spawn_file_actions_t *file_actions" 53*8ed1e4a5SKonstantin Belousov.Fa "const posix_spawnattr_t *restrict attrp" 54*8ed1e4a5SKonstantin Belousov.Fa "char *const argv[restrict]" 55*8ed1e4a5SKonstantin Belousov.Fa "char *const envp[restrict]" 56*8ed1e4a5SKonstantin Belousov.Fc 5762187b41SDavid Xu.Ft int 58*8ed1e4a5SKonstantin Belousov.Fo posix_spawnp 59*8ed1e4a5SKonstantin Belousov.Fa "pid_t *restrict pid" 60*8ed1e4a5SKonstantin Belousov.Fa "const char *restrict file" 61*8ed1e4a5SKonstantin Belousov.Fa "const posix_spawn_file_actions_t *file_actions" 62*8ed1e4a5SKonstantin Belousov.Fa "const posix_spawnattr_t *restrict attrp" 63*8ed1e4a5SKonstantin Belousov.Fa "char *const argv[restrict]" 64*8ed1e4a5SKonstantin Belousov.Fa "char *const envp[restrict]" 65*8ed1e4a5SKonstantin Belousov.Fc 6662187b41SDavid Xu.Sh DESCRIPTION 6762187b41SDavid XuThe 6862187b41SDavid Xu.Fn posix_spawn 6962187b41SDavid Xuand 7062187b41SDavid Xu.Fn posix_spawnp 7162187b41SDavid Xufunctions create a new process (child process) from the specified 7262187b41SDavid Xuprocess image. 7362187b41SDavid XuThe new process image is constructed from a regular executable 7462187b41SDavid Xufile called the new process image file. 7562187b41SDavid Xu.Pp 7662187b41SDavid XuWhen a C program is executed as the result of this call, it is 7762187b41SDavid Xuentered as a C-language function call as follows: 7862187b41SDavid Xu.Bd -literal -offset indent 7962187b41SDavid Xuint main(int argc, char *argv[]); 8062187b41SDavid Xu.Ed 8162187b41SDavid Xu.Pp 8262187b41SDavid Xuwhere 8362187b41SDavid Xu.Fa argc 8462187b41SDavid Xuis the argument count and 8562187b41SDavid Xu.Fa argv 8662187b41SDavid Xuis an array of character pointers to the arguments themselves. 8762187b41SDavid XuIn addition, the variable: 8862187b41SDavid Xu.Bd -literal -offset indent 8962187b41SDavid Xuextern char **environ; 9062187b41SDavid Xu.Ed 9162187b41SDavid Xu.Pp 9262187b41SDavid Xupoints to an array of character pointers to 9362187b41SDavid Xuthe environment strings. 9462187b41SDavid Xu.Pp 9562187b41SDavid XuThe argument 9662187b41SDavid Xu.Fa argv 9762187b41SDavid Xuis an array of character pointers to null-terminated 9862187b41SDavid Xustrings. 9962187b41SDavid XuThe last member of this array is a null pointer and is not counted 10062187b41SDavid Xuin 10162187b41SDavid Xu.Fa argc . 10262187b41SDavid XuThese strings constitute the argument list available to the new process 10362187b41SDavid Xuimage. 10462187b41SDavid XuThe value in 10562187b41SDavid Xu.Fa argv Ns [0] 10662187b41SDavid Xushould point to 10762187b41SDavid Xua filename that is associated with the process image being started by 10862187b41SDavid Xuthe 10962187b41SDavid Xu.Fn posix_spawn 11062187b41SDavid Xuor 11162187b41SDavid Xu.Fn posix_spawnp 11262187b41SDavid Xufunction. 11362187b41SDavid Xu.Pp 11462187b41SDavid XuThe argument 11562187b41SDavid Xu.Fa envp 11662187b41SDavid Xuis an array of character pointers to null-terminated strings. 11762187b41SDavid XuThese strings constitute the environment for the new process image. 11862187b41SDavid XuThe environment array is terminated by a null pointer. 11962187b41SDavid Xu.Pp 12062187b41SDavid XuThe 12162187b41SDavid Xu.Fa path 12262187b41SDavid Xuargument to 12362187b41SDavid Xu.Fn posix_spawn 12462187b41SDavid Xuis a pathname that identifies the new process image file to execute. 12562187b41SDavid Xu.Pp 12662187b41SDavid XuThe 12762187b41SDavid Xu.Fa file 12862187b41SDavid Xuparameter to 12962187b41SDavid Xu.Fn posix_spawnp 13062187b41SDavid Xuis used to construct a pathname that identifies the new process 13162187b41SDavid Xuimage file. 13262187b41SDavid XuIf the file parameter contains a slash character, the file parameter 13362187b41SDavid Xuis used as the pathname for the new process image file. 13462187b41SDavid XuOtherwise, the path prefix for this file is obtained by a search 13562187b41SDavid Xuof the directories passed as the environment variable 13662187b41SDavid Xu.Dq Ev PATH . 13762187b41SDavid XuIf this variable is not specified, 13862187b41SDavid Xuthe default path is set according to the 13962187b41SDavid Xu.Dv _PATH_DEFPATH 14062187b41SDavid Xudefinition in 14162187b41SDavid Xu.In paths.h , 14262187b41SDavid Xuwhich is set to 14343d53dbaSJilles Tjoelker.Dq Ev /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin . 14462187b41SDavid Xu.Pp 14562187b41SDavid XuIf 14662187b41SDavid Xu.Fa file_actions 14762187b41SDavid Xuis a null pointer, then file descriptors open in the 14862187b41SDavid Xucalling process remain open in the child process, except for those 14962187b41SDavid Xuwhose close-on-exec flag 15062187b41SDavid Xu.Dv FD_CLOEXEC 15162187b41SDavid Xuis set (see 15262187b41SDavid Xu.Fn fcntl ) . 15362187b41SDavid XuFor those 15462187b41SDavid Xufile descriptors that remain open, all attributes of the corresponding 15562187b41SDavid Xuopen file descriptions, including file locks (see 15662187b41SDavid Xu.Fn fcntl ) , 15762187b41SDavid Xuremain unchanged. 15862187b41SDavid Xu.Pp 15962187b41SDavid XuIf 16062187b41SDavid Xu.Fa file_actions 16162187b41SDavid Xuis not NULL, then the file descriptors open in the child process are 16262187b41SDavid Xuthose open in the calling process as modified by the spawn file 16362187b41SDavid Xuactions object pointed to by 16462187b41SDavid Xu.Fa file_actions 16562187b41SDavid Xuand the 16662187b41SDavid Xu.Dv FD_CLOEXEC 16762187b41SDavid Xuflag of each remaining open file descriptor after the spawn file actions 16862187b41SDavid Xuhave been processed. 16962187b41SDavid XuThe effective order of processing the spawn file actions are: 17062187b41SDavid Xu.Bl -enum 17162187b41SDavid Xu.It 17262187b41SDavid XuThe set of open file descriptors for the child process initially 17362187b41SDavid Xuare the same set as is open for the calling process. 17462187b41SDavid XuAll attributes of the corresponding open file descriptions, including 17562187b41SDavid Xufile locks (see 17662187b41SDavid Xu.Fn fcntl ) , 17762187b41SDavid Xuremain unchanged. 17862187b41SDavid Xu.It 17962187b41SDavid XuThe signal mask, signal default actions, and the effective user and 18062187b41SDavid Xugroup IDs for the child process are changed as specified in the 18162187b41SDavid Xuattributes object referenced by 18262187b41SDavid Xu.Fa attrp . 18362187b41SDavid Xu.It 18462187b41SDavid XuThe file actions specified by the spawn file actions object are 18562187b41SDavid Xuperformed in the order in which they were added to the spawn file 18662187b41SDavid Xuactions object. 18762187b41SDavid Xu.It 18862187b41SDavid XuAny file descriptor that has its 18962187b41SDavid Xu.Dv FD_CLOEXEC 19062187b41SDavid Xuflag set (see 19162187b41SDavid Xu.Fn fcntl ) 19262187b41SDavid Xuis closed. 19362187b41SDavid Xu.El 19462187b41SDavid Xu.Pp 19562187b41SDavid XuThe 19662187b41SDavid Xu.Vt posix_spawnattr_t 19762187b41SDavid Xuspawn attributes object type is defined in 19862187b41SDavid Xu.In spawn.h . 19962187b41SDavid XuIt contains the attributes defined below. 20062187b41SDavid Xu.Pp 20162187b41SDavid XuIf the 20262187b41SDavid Xu.Dv POSIX_SPAWN_SETPGROUP 20362187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 20462187b41SDavid Xu.Fa attrp , 20562187b41SDavid Xuand the spawn-pgroup attribute of the same object is non-zero, then the 20662187b41SDavid Xuchild's process group is as specified in the spawn-pgroup 20762187b41SDavid Xuattribute of the object referenced by 20862187b41SDavid Xu.Fa attrp . 20962187b41SDavid Xu.Pp 21062187b41SDavid XuAs a special case, if the 21162187b41SDavid Xu.Dv POSIX_SPAWN_SETPGROUP 21262187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 21362187b41SDavid Xu.Fa attrp , 21462187b41SDavid Xuand the spawn-pgroup attribute of the same object is set to zero, then 21562187b41SDavid Xuthe child is in a new process group with a process group ID equal 21662187b41SDavid Xuto its process ID. 21762187b41SDavid Xu.Pp 21862187b41SDavid XuIf the 21962187b41SDavid Xu.Dv POSIX_SPAWN_SETPGROUP 22062187b41SDavid Xuflag is not set in the spawn-flags attribute of the object referenced by 22162187b41SDavid Xu.Fa attrp , 22262187b41SDavid Xuthe new child process inherits the parent's process group. 22362187b41SDavid Xu.Pp 22462187b41SDavid XuIf the 22562187b41SDavid Xu.Dv POSIX_SPAWN_SETSCHEDPARAM 22662187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 22762187b41SDavid Xu.Fa attrp , 22862187b41SDavid Xubut 22962187b41SDavid Xu.Dv POSIX_SPAWN_SETSCHEDULER 23062187b41SDavid Xuis not set, the new process image initially has the scheduling 23162187b41SDavid Xupolicy of the calling process with the scheduling parameters specified 23262187b41SDavid Xuin the spawn-schedparam attribute of the object referenced by 23362187b41SDavid Xu.Fa attrp . 23462187b41SDavid Xu.Pp 23562187b41SDavid XuIf the 23662187b41SDavid Xu.Dv POSIX_SPAWN_SETSCHEDULER 23762187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 23862187b41SDavid Xu.Fa attrp 23962187b41SDavid Xu(regardless of the setting of the 24062187b41SDavid Xu.Dv POSIX_SPAWN_SETSCHEDPARAM 24162187b41SDavid Xuflag), the new process image initially has the scheduling policy 24262187b41SDavid Xuspecified in the spawn-schedpolicy attribute of the object referenced by 24362187b41SDavid Xu.Fa attrp 24462187b41SDavid Xuand the scheduling parameters specified in the spawn-schedparam 24562187b41SDavid Xuattribute of the same object. 24662187b41SDavid Xu.Pp 24762187b41SDavid XuThe 24862187b41SDavid Xu.Dv POSIX_SPAWN_RESETIDS 24962187b41SDavid Xuflag in the spawn-flags attribute of the object referenced by 25062187b41SDavid Xu.Fa attrp 25162187b41SDavid Xugoverns the effective user ID of the child process. 25262187b41SDavid XuIf this flag is not set, the child process inherits the parent 25362187b41SDavid Xuprocess' effective user ID. 25462187b41SDavid XuIf this flag is set, the child process' effective user ID is reset 25562187b41SDavid Xuto the parent's real user ID. 25662187b41SDavid XuIn either case, if the set-user-ID mode bit of the new process image 25762187b41SDavid Xufile is set, the effective user ID of the child process becomes 25862187b41SDavid Xuthat file's owner ID before the new process image begins execution. 25962187b41SDavid Xu.Pp 26062187b41SDavid XuThe 26162187b41SDavid Xu.Dv POSIX_SPAWN_RESETIDS 26262187b41SDavid Xuflag in the spawn-flags attribute of the object referenced by 26362187b41SDavid Xu.Fa attrp 26462187b41SDavid Xualso governs the effective group ID of the child process. 26562187b41SDavid XuIf this flag is not set, the child process inherits the parent 26662187b41SDavid Xuprocess' effective group ID. 26762187b41SDavid XuIf this flag is set, the child process' effective group ID is 26862187b41SDavid Xureset to the parent's real group ID. 26962187b41SDavid XuIn either case, if the set-group-ID mode bit of the new process image 27062187b41SDavid Xufile is set, the effective group ID of the child process becomes 27162187b41SDavid Xuthat file's group ID before the new process image begins execution. 27262187b41SDavid Xu.Pp 27362187b41SDavid XuIf the 27462187b41SDavid Xu.Dv POSIX_SPAWN_SETSIGMASK 27562187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 27662187b41SDavid Xu.Fa attrp , 27762187b41SDavid Xuthe child process initially has the signal mask specified in the 27862187b41SDavid Xuspawn-sigmask attribute of the object referenced by 27962187b41SDavid Xu.Fa attrp . 28062187b41SDavid Xu.Pp 28162187b41SDavid XuIf the 28262187b41SDavid Xu.Dv POSIX_SPAWN_SETSIGDEF 28362187b41SDavid Xuflag is set in the spawn-flags attribute of the object referenced by 28462187b41SDavid Xu.Fa attrp , 28562187b41SDavid Xuthe signals specified in the spawn-sigdefault attribute of the same 2868d55975fSBryan Dreweryobject are set to their default actions in the child process. 2878d55975fSBryan DrewerySignals set to the default action in the parent process are set to 28862187b41SDavid Xuthe default action in the child process. 28962187b41SDavid Xu.Pp 2908d55975fSBryan DrewerySignals set to be caught by the calling process are set to the 29162187b41SDavid Xudefault action in the child process. 29262187b41SDavid Xu.Pp 2938d55975fSBryan DrewerySignals set to be ignored by the calling process image are set to 29462187b41SDavid Xube ignored by the child process, unless otherwise specified by the 29562187b41SDavid Xu.Dv POSIX_SPAWN_SETSIGDEF 29662187b41SDavid Xuflag being set in the spawn-flags attribute of the object referenced by 29762187b41SDavid Xu.Fa attrp 29862187b41SDavid Xuand the signals being indicated in the spawn-sigdefault attribute 29962187b41SDavid Xuof the object referenced by 30062187b41SDavid Xu.Fa attrp . 30162187b41SDavid Xu.Pp 30262187b41SDavid XuIf the value of the 30362187b41SDavid Xu.Fa attrp 30462187b41SDavid Xupointer is NULL, then the default values are used. 30562187b41SDavid Xu.Pp 30662187b41SDavid XuAll process attributes, other than those influenced by the attributes 30762187b41SDavid Xuset in the object referenced by 30862187b41SDavid Xu.Fa attrp 30962187b41SDavid Xuas specified above or by the file descriptor manipulations specified in 31062187b41SDavid Xu.Fa file_actions , 31162187b41SDavid Xuappear in the new process image as though 31262187b41SDavid Xu.Fn vfork 31362187b41SDavid Xuhad been called to create a child process and then 31462187b41SDavid Xu.Fn execve 31562187b41SDavid Xuhad been called by the child process to execute the new process image. 31662187b41SDavid Xu.Pp 3172c96ea9cSEnji CooperThe implementation uses 3182c96ea9cSEnji Cooper.Fn vfork , 3192c96ea9cSEnji Cooperthus the fork handlers are not run when 32062187b41SDavid Xu.Fn posix_spawn 32162187b41SDavid Xuor 32262187b41SDavid Xu.Fn posix_spawnp 32362187b41SDavid Xuis called. 32462187b41SDavid Xu.Sh RETURN VALUES 32562187b41SDavid XuUpon successful completion, 32662187b41SDavid Xu.Fn posix_spawn 32762187b41SDavid Xuand 32862187b41SDavid Xu.Fn posix_spawnp 32962187b41SDavid Xureturn the process ID of the child process to the parent process, 33062187b41SDavid Xuin the variable pointed to by a non-NULL 33162187b41SDavid Xu.Fa pid 33262187b41SDavid Xuargument, and return zero as the function return value. 33362187b41SDavid XuOtherwise, no child process is created, no value is stored into 33462187b41SDavid Xuthe variable pointed to by 33562187b41SDavid Xu.Fa pid , 33662187b41SDavid Xuand an error number is returned as the function return value to 33762187b41SDavid Xuindicate the error. 33862187b41SDavid XuIf the 33962187b41SDavid Xu.Fa pid 34062187b41SDavid Xuargument is a null pointer, the process ID of the child is not returned 34162187b41SDavid Xuto the caller. 34262187b41SDavid Xu.Sh ERRORS 34362187b41SDavid Xu.Bl -enum 34462187b41SDavid Xu.It 34562187b41SDavid XuIf 34662187b41SDavid Xu.Fn posix_spawn 34762187b41SDavid Xuand 34862187b41SDavid Xu.Fn posix_spawnp 34962187b41SDavid Xufail for any of the reasons that would cause 35062187b41SDavid Xu.Fn vfork 35162187b41SDavid Xuor one of the 35262187b41SDavid Xu.Nm exec 35362187b41SDavid Xuto fail, an error value is returned as described by 35462187b41SDavid Xu.Fn vfork 35562187b41SDavid Xuand 35662187b41SDavid Xu.Nm exec , 35762187b41SDavid Xurespectively (or, if the error occurs after the calling process successfully 35862187b41SDavid Xureturns, the child process exits with exit status 127). 35962187b41SDavid Xu.It 36062187b41SDavid XuIf 36162187b41SDavid Xu.Nm POSIX_SPAWN_SETPGROUP 36262187b41SDavid Xuis set in the spawn-flags attribute of the object referenced by attrp, and 36362187b41SDavid Xu.Fn posix_spawn 36462187b41SDavid Xuor 36562187b41SDavid Xu.Fn posix_spawnp 36662187b41SDavid Xufails while changing the child's process group, an error value is returned as 36762187b41SDavid Xudescribed by 36862187b41SDavid Xu.Fn setpgid 36962187b41SDavid Xu(or, if the error occurs after the calling process successfully returns, 37062187b41SDavid Xuthe child process exits with exit status 127). 37162187b41SDavid Xu.It 37262187b41SDavid XuIf 37362187b41SDavid Xu.Nm POSIX_SPAWN_SETSCHEDPARAM 37462187b41SDavid Xuis set and 37562187b41SDavid Xu.Nm POSIX_SPAWN_SETSCHEDULER 37662187b41SDavid Xuis not set in the spawn-flags attribute of the object referenced by attrp, then 37762187b41SDavid Xuif 37862187b41SDavid Xu.Fn posix_spawn 37962187b41SDavid Xuor 38062187b41SDavid Xu.Fn posix_spawnp 38162187b41SDavid Xufails for any of the reasons that would cause 38262187b41SDavid Xu.Fn sched_setparam 38362187b41SDavid Xuto fail, an error value is returned as described by 38462187b41SDavid Xu.Fn sched_setparam 38562187b41SDavid Xu(or, if the error occurs after the calling process successfully returns, the 38662187b41SDavid Xuchild process exits with exit status 127). 38762187b41SDavid Xu.It 38862187b41SDavid XuIf 38962187b41SDavid Xu.Nm POSIX_SPAWN_SETSCHEDULER 39062187b41SDavid Xuis set in the spawn-flags attribute of the object referenced by attrp, and if 39162187b41SDavid Xu.Fn posix_spawn 39262187b41SDavid Xuor 39362187b41SDavid Xu.Fn posix_spawnp 39462187b41SDavid Xufails for any of the reasons that would cause 39562187b41SDavid Xu.Fn sched_setscheduler 39662187b41SDavid Xuto fail, an error value is returned as described by 39762187b41SDavid Xu.Fn sched_setscheduler 39862187b41SDavid Xu(or, if the error occurs after the calling process successfully returns, 39962187b41SDavid Xuthe child process exits with exit status 127). 40062187b41SDavid Xu.It 40162187b41SDavid XuIf the 40262187b41SDavid Xu.Fa file_actions 403876b6796SJilles Tjoelkerargument is not NULL, and specifies any dup2 or open actions to be 40462187b41SDavid Xuperformed, and if 40562187b41SDavid Xu.Fn posix_spawn 40662187b41SDavid Xuor 40762187b41SDavid Xu.Fn posix_spawnp 40862187b41SDavid Xufails for any of the reasons that would cause 409876b6796SJilles Tjoelker.Fn dup2 41062187b41SDavid Xuor 41162187b41SDavid Xu.Fn open 41262187b41SDavid Xuto fail, an error value is returned as described by 413876b6796SJilles Tjoelker.Fn dup2 41462187b41SDavid Xuand 41562187b41SDavid Xu.Fn open , 41662187b41SDavid Xurespectively (or, if the error occurs after the calling process successfully 41762187b41SDavid Xureturns, the child process exits with exit status 127). An open file action 41862187b41SDavid Xumay, by itself, result in any of the errors described by 41962187b41SDavid Xu.Fn dup2 , 42062187b41SDavid Xuin addition to those described by 42162187b41SDavid Xu.Fn open . 422876b6796SJilles TjoelkerThis implementation ignores any errors from 423876b6796SJilles Tjoelker.Fn close , 424876b6796SJilles Tjoelkerincluding trying to close a descriptor that is not open. 42562187b41SDavid Xu.El 42662187b41SDavid Xu.Sh SEE ALSO 42762187b41SDavid Xu.Xr close 2 , 42862187b41SDavid Xu.Xr dup2 2 , 42962187b41SDavid Xu.Xr execve 2 , 43062187b41SDavid Xu.Xr fcntl 2 , 43162187b41SDavid Xu.Xr open 2 , 4320aee91e1SChristian Brueffer.Xr sched_setparam 2 , 4330aee91e1SChristian Brueffer.Xr sched_setscheduler 2 , 4340aee91e1SChristian Brueffer.Xr setpgid 2 , 4350aee91e1SChristian Brueffer.Xr vfork 2 , 43662187b41SDavid Xu.Xr posix_spawn_file_actions_addclose 3 , 43762187b41SDavid Xu.Xr posix_spawn_file_actions_adddup2 3 , 43862187b41SDavid Xu.Xr posix_spawn_file_actions_addopen 3 , 43962187b41SDavid Xu.Xr posix_spawn_file_actions_destroy 3 , 44062187b41SDavid Xu.Xr posix_spawn_file_actions_init 3 , 44162187b41SDavid Xu.Xr posix_spawnattr_destroy 3 , 44262187b41SDavid Xu.Xr posix_spawnattr_getflags 3 , 44362187b41SDavid Xu.Xr posix_spawnattr_getpgroup 3 , 44462187b41SDavid Xu.Xr posix_spawnattr_getschedparam 3 , 44562187b41SDavid Xu.Xr posix_spawnattr_getschedpolicy 3 , 44662187b41SDavid Xu.Xr posix_spawnattr_getsigdefault 3 , 44762187b41SDavid Xu.Xr posix_spawnattr_getsigmask 3 , 44862187b41SDavid Xu.Xr posix_spawnattr_init 3 , 44962187b41SDavid Xu.Xr posix_spawnattr_setflags 3 , 45062187b41SDavid Xu.Xr posix_spawnattr_setpgroup 3 , 45162187b41SDavid Xu.Xr posix_spawnattr_setschedparam 3 , 45262187b41SDavid Xu.Xr posix_spawnattr_setschedpolicy 3 , 45362187b41SDavid Xu.Xr posix_spawnattr_setsigdefault 3 , 4540aee91e1SChristian Brueffer.Xr posix_spawnattr_setsigmask 3 45562187b41SDavid Xu.Sh STANDARDS 45662187b41SDavid XuThe 45762187b41SDavid Xu.Fn posix_spawn 45862187b41SDavid Xuand 45962187b41SDavid Xu.Fn posix_spawnp 46062187b41SDavid Xufunctions conform to 461876b6796SJilles Tjoelker.St -p1003.1-2001 , 462876b6796SJilles Tjoelkerexcept that they ignore all errors from 463876b6796SJilles Tjoelker.Fn close . 464876b6796SJilles TjoelkerA future update of the Standard is expected to require that these functions 465876b6796SJilles Tjoelkernot fail because a file descriptor to be closed (via 466876b6796SJilles Tjoelker.Fn posix_spawn_file_actions_addclose ) 467876b6796SJilles Tjoelkeris not open. 46862187b41SDavid Xu.Sh HISTORY 46962187b41SDavid XuThe 47062187b41SDavid Xu.Fn posix_spawn 47162187b41SDavid Xuand 47262187b41SDavid Xu.Fn posix_spawnp 47362187b41SDavid Xufunctions first appeared in 47462187b41SDavid Xu.Fx 8.0 . 47562187b41SDavid Xu.Sh AUTHORS 47618c5321dSBaptiste Daroussin.An \&Ed Schouten Aq Mt ed@FreeBSD.org 477