Update contrib.
1 /** @file ../include/spawn.h
5 /** @def POSIX_SPAWN_RESETIDS
7 Flags that can be set in posix_spawnattr_t.
8 The POSIX_SPAWN_RESETIDS flag in the spawn-flags attribute of the object referenced by attrp governs the effective user ID of the child process. If this flag is not set, the child process shall inherit the parent process' effective user ID.
9 If this flag is set, the child process' effective user ID shall be reset to the parent's real user ID. In either case, if the set-user-ID mode bit of the new process image file is set, the effective user ID of the child process shall become that file's owner ID before the new process image begins execution.
15 /** @def POSIX_SPAWN_SETPGROUP
17 Flags that can be set in posix_spawnattr_t
18 If the POSIX_SPAWN_SETPGROUP flag is set in the spawn-flags attribute of the object referenced by attrp, and the spawn-pgroup attribute of the same object is non-zero,
19 then the child's process group shall be as specified in the spawn-pgroup attribute of the object referenced by attrp.
25 /** @def POSIX_SPAWN_SETSIGDEF
27 Flags that can be set in posix_spawnattr_t
28 If the POSIX_SPAWN_SETSIGDEF flag is set in the spawn-flags attribute of the object referenced by attrp, the signals specified in the spawn-sigdefault attribute of the same object shall be set to their default actions in the child process.
29 Signals set to the default action in the parent process shall be set to the default action in the child process.
35 /** @def POSIX_SPAWN_SETSIGMASK
37 Flags that can be set in posix_spawnattr_t
38 If the POSIX_SPAWN_SETSIGMASK flag is set in the spawn-flags attribute of the object referenced by attrp, the child process shall initially have the signal mask specified in the spawn-sigmask attribute of the object referenced by attrp.
44 /** @def POSIX_SPAWN_SETSCHEDPARAM
46 Flags that can be set in posix_spawnattr_t
47 If the POSIX_SPAWN_SETSCHEDPARAM flag is set in the spawn-flags attribute of the object referenced by attrp, but POSIX_SPAWN_SETSCHEDULER is not set, the new process image shall initially have the scheduling policy of the calling process with the scheduling parameters specified in the spawn-schedparam attribute of the object referenced by attrp.
53 /** @def POSIX_SPAWN_SETSCHEDULER
55 Flags that can be set in posix_spawnattr_t
56 If the POSIX_SPAWN_SETSCHEDULER flag is set in the spawn-flags attribute of the object referenced by attrp (regardless of the setting of the POSIX_SPAWN_SETSCHEDPARAM flag), the new process image shall initially have the scheduling policy specified in the spawn-schedpolicy attribute of the object referenced by attrp and the scheduling parameters specified in the spawn-schedparam attribute of the same object.
62 /** @fn posix_spawn(int* aPid, const wchar_t* aFile, const posix_spawn_file_actions_t* aFileActions, const posix_spawnattr_t* attrp, const wchar_t* aArgs, wchar_t** aEnvp)
69 @return Upon successful completion, posix_spawn() and posix_spawnp() shall return the process ID of the child process to the parent process, in the variable pointed to by a non-NULL aPid argument, and shall return zero as the function return value. Otherwise, no child process shall be created, the value stored into the variable pointed to by a non-NULL aPid is unspecified, and an error number shall be returned as the function return value to indicate the error. If the pid argument is a null pointer, the process ID of the child is not returned to the caller.
71 The posix_spawn() and posix_spawnp() functions shall create a new process (child process) from the specified process image. The new process image shall be constructed from a regular executable file called the new process image file.
73 Note: When a child process created using posix_spawn() exits, the parent process receives a SIGCHLD signal.
77 When a C program is executed as the result of this call, it shall be entered as a C-language function call as follows:
78 int main(int argc, char *aArgs[]);
79 where argc is the argument count and aArgs is an array of character pointers to the arguments themselves. In addition, the following variable:
80 extern char **environ;
81 shall be initialized as a pointer to an array of character pointers to the environment strings.
85 The argument aArgs is an array of character pointers to null-terminated strings. The last member of this array shall be a null pointer and is not counted in argc. These strings constitute the argument list available to the new process image. The value in aArgs[0] should point to a filename that is associated with the process image being started by the posix_spawn() or posix_spawnp() function.
87 The argument aEnvp is an array of character pointers to null-terminated strings. These strings constitute the environment for the new process image. The environment array is terminated by a null pointer.
88 The aFile argument to posix_spawn() is a pathname that identifies the new process image file to execute.
90 If aFileActions is a null pointer, then file descriptors open in the calling process shall remain open in the child process, except for those whose close-on- exec flag FD_CLOEXEC is set (see fcntl() ). For those file descriptors that remain open, all attributes of the corresponding open file descriptions, including file locks (see fcntl() ), shall remain unchanged.
92 If aFileActions is not NULL, then the file descriptors open in the child process shall be those open in the calling process as modified by the spawn file actions object pointed to by file_actions and the FD_CLOEXEC flag of each remaining open file descriptor after the spawn file actions have been processed. The effective order of processing the spawn file actions shall be:
95 1. The set of open file descriptors for the child process shall initially be the same set as is open for the calling process. All attributes of the corresponding open file descriptions, including file locks (see fcntl() ), shall remain unchanged.
96 2. The signal mask, signal default actions, and the effective user and group IDs for the child process shall be changed as specified in the attributes object referenced by attrp.
97 3. The file actions specified by the spawn file actions object shall be performed in the order in which they were added to the spawn file actions object.
98 4. Any file descriptor that has its FD_CLOEXEC flag set (see fcntl() ) shall be closed.
101 The posix_spawn() and posix_spawnp() functions may fail if:
103 [EINVAL] The value specified by file_actions or attrp is invalid.
106 @externallyDefinedApi
109 /** @fn posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* file_actions, int fid)
112 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
114 Add a close action to the file actions structure
115 The posix_spawn_file_actions_addclose() function shall add a close action to the object referenced by file_actions that shall cause the file descriptor fildes to be closed (as if close( fildes) had been called) when a new process is spawned using this file actions object.
117 A spawn file actions object is of type posix_spawn_file_actions_t (defined in <spawn.h>) and is used to specify a series of actions to be performed by a posix_spawn() or posix_spawnp() operation in order to arrive at the set of open file descriptors for the child process given the set of open file descriptors of the parent.
118 These functions shall fail if:
121 [EBADF] The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.
122 These functions may fail if:
123 [EINVAL] The value specified by file_actions is invalid.
124 [ENOMEM] Insufficient memory exists to add to the spawn file actions object.
128 @externallyDefinedApi
131 /** @fn posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* file_actions, int fid1,int fid2)
135 @return Upon successful completion, the posix_spawn_file_actions_adddup2() function shall return zero; otherwise, an error number shall be returned to indicate the error.
137 Add a dup2 action to the file actions structure
139 The posix_spawn_file_actions_adddup2() function shall add a dup2() action to the object referenced by file_actions that shall cause the file descriptor fildes to be duplicated as newfildes (as if dup2( fid1, fid2) had been called) when a new process is spawned using this file actions object.
142 The posix_spawn_file_actions_adddup2() function shall fail if:
144 [EBADF] The value specified by fildes or newfildes is negative or greater than or equal to {OPEN_MAX}.
145 [ENOMEM] Insufficient memory exists to add to the spawn file actions object.
146 The posix_spawn_file_actions_adddup2() function may fail if:
147 [EINVAL] The value specified by file_actions is invalid.
151 @externallyDefinedApi
154 /** @fn posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* file_actions, int fid,const char* path, int oflag, mode_t mode)
160 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
162 Add an open action to the file actions structure
164 The posix_spawn_file_actions_addopen() function shall add an open action to the object referenced by file_actions that shall cause the file named by path to be opened (as if open( path, oflag, mode) had been called, and the returned file descriptor, if not fid, had been changed to fid) when a new process is spawned using this file actions object.
165 If fid was already an open file descriptor, it shall be closed before the new file is opened.
168 These functions shall fail if:
169 [EBADF] The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.
170 These functions may fail if:
171 [EINVAL] The value specified by file_actions is invalid.
172 [ENOMEM] Insufficient memory exists to add to the spawn file actions object.
176 @externallyDefinedApi
179 /** @fn posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* file_actions)
181 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
183 Empty and destroy the file actions structure.
184 The posix_spawn_file_actions_destroy() function shall destroy the object referenced by file_actions; the object becomes, in effect, uninitialized. An implementation may cause posix_spawn_file_actions_destroy() to set the object referenced by file_actions to an invalid value. A destroyed spawn file actions object can be reinitialized using posix_spawn_file_actions_init(); the results of otherwise referencing the object after it has been destroyed are undefined.
187 @externallyDefinedApi
190 /** @fn posix_spawn_file_actions_init(posix_spawn_file_actions_t* file_actions)
192 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
194 Initialize the file actions structure.
196 The posix_spawn_file_actions_init() function shall fail if:
197 [ENOMEM] Insufficient memory exists to initialize the spawn file actions object.
200 @externallyDefinedApi
203 /** @fn posix_spawnattr_destroy(posix_spawnattr_t* attrp)
207 Empty and cleanup the spawn attributes structure
210 @externallyDefinedApi
213 /** @fn posix_spawnattr_getsigdefault(const posix_spawnattr_t* attrp, sigset_t* sigdefault)
216 @return Returns the sigdefault attribute
218 The posix_spawnattr_getsigdefault() function shall obtain the value of the spawn-sigdefault attribute from the attributes object referenced by attrp.
221 @externallyDefinedApi
224 /** @fn posix_spawnattr_getflags(const posix_spawnattr_t* attrp,short* flags)
227 @return Return the flags attribute
229 The posix_spawnattr_getflags() function shall obtain the value of the spawn-flags attribute from the attributes object referenced by attrp.
231 These functions may fail if:
232 [EINVAL] The value specified by attrp is invalid.
235 @externallyDefinedApi
238 /** @fn posix_spawnattr_getpgroup(const posix_spawnattr_t* attrp, pid_t* pgroup)
241 @return Return the process group attribute
243 The posix_spawnattr_getpgroup() function shall obtain the value of the spawn-pgroup attribute from the attributes object referenced by attrp.
245 These functions may fail if:
246 [EINVAL] The value specified by attrp is invalid.
249 @externallyDefinedApi
252 /** @fn posix_spawnattr_getschedparam(const posix_spawnattr_t* attrp,struct sched_param* schedparam)
255 @return Return scheduling parameters attribute
257 The posix_spawnattr_getschedparam() function shall obtain the value of the spawn-schedparam attribute from the attributes object referenced by attrp.
259 These functions may fail if:
260 [EINVAL] The value specified by attrp is invalid.
263 @externallyDefinedApi
266 /** @fn posix_spawnattr_getschedpolicy(const posix_spawnattr_t* attrp, int* policy)
269 @return Return the scheduling policy attribute
271 The posix_spawnattr_getschedpolicy() function shall obtain the value of the spawn-schedpolicy attribute from the attributes object referenced by attrp.
273 These functions may fail if:
274 [EINVAL] The value specified by attrp is invalid.
277 @externallyDefinedApi
280 /** @fn posix_spawnattr_getsigmask(const posix_spawnattr_t* attrp, sigset_t* sigmask)
283 @return Return the signal mask attribute
285 The posix_spawnattr_getsigmask() function shall obtain the value of the spawn-sigmask attribute from the attributes object referenced by attrp.
287 These functions may fail if:
288 [EINVAL] The value specified by attrp is invalid.
291 @externallyDefinedApi
294 /** @fn posix_spawnattr_init(posix_spawnattr_t* attrp)
296 @return Upon successful completion, posix_spawnattr_destroy() and posix_spawnattr_init() shall return zero; otherwise, an error number shall be returned to indicate the error.
298 Initialize the spawn attributes structure.
299 The posix_spawnattr_init() function shall initialize a spawn attributes object attr with the default value for all of the individual attributes used by the implementation. Results are undefined if posix_spawnattr_init() is called specifying an already initialized attr attributes object.
301 The posix_spawnattr_init() function shall fail if:
302 [ENOMEM] Insufficient memory exists to initialize the spawn attributes object.
305 @externallyDefinedApi
308 /** @fn posix_spawnattr_setsigdefault(posix_spawnattr_t* attrp,const sigset_t* sigdefault)
311 @return Upon successful completion, posix_spawnattr_setsigdefault() shall return zero; otherwise, an error number shall be returned to indicate the error.
313 The posix_spawnattr_setsigdefault() function shall set the spawn-sigdefault attribute in an initialized attributes object referenced by attrp.
315 The posix_spawnattr_setsigdefault() function may fail if:
316 [EINVAL] The value of the attribute being set is not valid.
319 @externallyDefinedApi
322 /** @fn posix_spawnattr_setflags(posix_spawnattr_t* attrp, short flags)
325 @return Upon successful completion, posix_spawnattr_setflags() shall return zero; otherwise, an error number shall be returned to indicate the error.
327 The posix_spawnattr_setflags() function shall set the spawn-flags attribute in an initialized attributes object referenced by attrp.
329 The posix_spawnattr_setflags() function may fail if:
330 [EINVAL] The value of the attribute being set is not valid.
333 @externallyDefinedApi
336 /** @fn posix_spawnattr_setpgroup(posix_spawnattr_t* attrp, pid_t pgroup)
339 @return Upon successful completion, posix_spawnattr_setpgroup() shall return zero; otherwise, an error number shall be returned to indicate the error.
341 Sets the process group attribute
342 The posix_spawnattr_setpgroup() function shall set the spawn-pgroup attribute in an initialized attributes object referenced by attrp.
344 The spawn-pgroup attribute represents the process group to be joined by the new process image in a spawn operation (if POSIX_SPAWN_SETPGROUP is set in the spawn-flags attribute). The default value of this attribute shall be zero.
345 The posix_spawnattr_setpgroup() function may fail if:
346 [EINVAL]The value of the attribute being set is not valid.
349 @externallyDefinedApi
352 /** @fn posix_spawnattr_setschedparam(posix_spawnattr_t* attrp,const struct sched_param* schedparam)
355 @return Upon successful completion, posix_spawnattr_setschedparam() shall return zero; otherwise, an error number shall be returned to indicate the error.
357 Sets the scheduling parameters attribute.
358 The posix_spawnattr_setschedparam() function shall set the spawn-schedparam attribute in an initialized attributes object referenced by attrp.
360 The posix_spawnattr_setschedparam() function may fail if:
362 EINVAL The value of the attribute being set is not valid.
365 @externallyDefinedApi
368 /** @fn posix_spawnattr_setschedpolicy(posix_spawnattr_t* attrp, int policy)
371 @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error.
373 The posix_spawnattr_setschedpolicy() function shall set the spawn-schedpolicy attribute in an initialized attributes object referenced by attrp.
375 The posix_spawnattr_setschedpolicy() function may fail if:
376 EINVAL The value of the attribute being set is not valid.
379 @externallyDefinedApi
382 /** @fn posix_spawnattr_setsigmask(posix_spawnattr_t* attrp, const sigset_t* sigmask)
385 @return @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error.
388 Sets the sigmask attribute.
389 The posix_spawnattr_setsigmask() function shall set the spawn-sigmask attribute in an initialized attributes object referenced by attrp.
391 The posix_spawnattr_setsigmask() function may fail if:
393 EINVAL The value of the attribute being set is not valid.
396 @externallyDefinedApi