sl@0: /** @file ../include/spawn.h sl@0: @internalComponent sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_RESETIDS sl@0: sl@0: Flags that can be set in posix_spawnattr_t. sl@0: 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. sl@0: 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. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_SETPGROUP sl@0: sl@0: Flags that can be set in posix_spawnattr_t sl@0: 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, sl@0: then the child's process group shall be as specified in the spawn-pgroup attribute of the object referenced by attrp. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_SETSIGDEF sl@0: sl@0: Flags that can be set in posix_spawnattr_t sl@0: 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. sl@0: Signals set to the default action in the parent process shall be set to the default action in the child process. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_SETSIGMASK sl@0: sl@0: Flags that can be set in posix_spawnattr_t sl@0: 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. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_SETSCHEDPARAM sl@0: sl@0: Flags that can be set in posix_spawnattr_t sl@0: 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. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def POSIX_SPAWN_SETSCHEDULER sl@0: sl@0: Flags that can be set in posix_spawnattr_t sl@0: 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. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @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) sl@0: @param aPid sl@0: @param aFile sl@0: @param aFileActions sl@0: @param attrp sl@0: @param aArgs sl@0: @param aEnvp sl@0: @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. sl@0: sl@0: 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. sl@0: sl@0: Note: When a child process created using posix_spawn() exits, the parent process receives a SIGCHLD signal. sl@0: sl@0: @code sl@0: sl@0: When a C program is executed as the result of this call, it shall be entered as a C-language function call as follows: sl@0: int main(int argc, char *aArgs[]); sl@0: where argc is the argument count and aArgs is an array of character pointers to the arguments themselves. In addition, the following variable: sl@0: extern char **environ; sl@0: shall be initialized as a pointer to an array of character pointers to the environment strings. sl@0: sl@0: @endcode sl@0: sl@0: 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. sl@0: sl@0: 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. sl@0: The aFile argument to posix_spawn() is a pathname that identifies the new process image file to execute. sl@0: sl@0: 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. sl@0: sl@0: 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: sl@0: sl@0: @code sl@0: 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. sl@0: 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. sl@0: 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. sl@0: 4. Any file descriptor that has its FD_CLOEXEC flag set (see fcntl() ) shall be closed. sl@0: @endcode sl@0: sl@0: The posix_spawn() and posix_spawnp() functions may fail if: sl@0: sl@0: [EINVAL] The value specified by file_actions or attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* file_actions, int fid) sl@0: @param file_actions sl@0: @param fid sl@0: @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Add a close action to the file actions structure sl@0: 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. sl@0: sl@0: A spawn file actions object is of type posix_spawn_file_actions_t (defined in ) 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. sl@0: These functions shall fail if: sl@0: sl@0: @code sl@0: [EBADF] The value specified by fildes is negative or greater than or equal to {OPEN_MAX}. sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by file_actions is invalid. sl@0: [ENOMEM] Insufficient memory exists to add to the spawn file actions object. sl@0: @encode sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* file_actions, int fid1,int fid2) sl@0: @param file_actions sl@0: @param fid1 sl@0: @param fid2 sl@0: @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. sl@0: sl@0: Add a dup2 action to the file actions structure sl@0: sl@0: 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. sl@0: sl@0: @code sl@0: The posix_spawn_file_actions_adddup2() function shall fail if: sl@0: sl@0: [EBADF] The value specified by fildes or newfildes is negative or greater than or equal to {OPEN_MAX}. sl@0: [ENOMEM] Insufficient memory exists to add to the spawn file actions object. sl@0: The posix_spawn_file_actions_adddup2() function may fail if: sl@0: [EINVAL] The value specified by file_actions is invalid. sl@0: @encode sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* file_actions, int fid,const char* path, int oflag, mode_t mode) sl@0: @param file_actions sl@0: @param fid sl@0: @param path sl@0: @param oflag sl@0: @param mode sl@0: @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Add an open action to the file actions structure sl@0: sl@0: 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. sl@0: If fid was already an open file descriptor, it shall be closed before the new file is opened. sl@0: sl@0: @code sl@0: These functions shall fail if: sl@0: [EBADF] The value specified by fildes is negative or greater than or equal to {OPEN_MAX}. sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by file_actions is invalid. sl@0: [ENOMEM] Insufficient memory exists to add to the spawn file actions object. sl@0: @encode sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* file_actions) sl@0: @param file_actions sl@0: @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Empty and destroy the file actions structure. sl@0: 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. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawn_file_actions_init(posix_spawn_file_actions_t* file_actions) sl@0: @param file_actions sl@0: @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Initialize the file actions structure. sl@0: sl@0: The posix_spawn_file_actions_init() function shall fail if: sl@0: [ENOMEM] Insufficient memory exists to initialize the spawn file actions object. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_destroy(posix_spawnattr_t* attrp) sl@0: @param attrp sl@0: @return Returns 0 sl@0: sl@0: Empty and cleanup the spawn attributes structure sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getsigdefault(const posix_spawnattr_t* attrp, sigset_t* sigdefault) sl@0: @param attrp sl@0: @param sigdefault sl@0: @return Returns the sigdefault attribute sl@0: sl@0: The posix_spawnattr_getsigdefault() function shall obtain the value of the spawn-sigdefault attribute from the attributes object referenced by attrp. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getflags(const posix_spawnattr_t* attrp,short* flags) sl@0: @param attrp sl@0: @param flags sl@0: @return Return the flags attribute sl@0: sl@0: The posix_spawnattr_getflags() function shall obtain the value of the spawn-flags attribute from the attributes object referenced by attrp. sl@0: sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getpgroup(const posix_spawnattr_t* attrp, pid_t* pgroup) sl@0: @param attrp sl@0: @param pgroup sl@0: @return Return the process group attribute sl@0: sl@0: The posix_spawnattr_getpgroup() function shall obtain the value of the spawn-pgroup attribute from the attributes object referenced by attrp. sl@0: sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getschedparam(const posix_spawnattr_t* attrp,struct sched_param* schedparam) sl@0: @param attrp sl@0: @param schedparam sl@0: @return Return scheduling parameters attribute sl@0: sl@0: The posix_spawnattr_getschedparam() function shall obtain the value of the spawn-schedparam attribute from the attributes object referenced by attrp. sl@0: sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getschedpolicy(const posix_spawnattr_t* attrp, int* policy) sl@0: @param attrp sl@0: @param policy sl@0: @return Return the scheduling policy attribute sl@0: sl@0: The posix_spawnattr_getschedpolicy() function shall obtain the value of the spawn-schedpolicy attribute from the attributes object referenced by attrp. sl@0: sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_getsigmask(const posix_spawnattr_t* attrp, sigset_t* sigmask) sl@0: @param attrp sl@0: @param sigmask sl@0: @return Return the signal mask attribute sl@0: sl@0: The posix_spawnattr_getsigmask() function shall obtain the value of the spawn-sigmask attribute from the attributes object referenced by attrp. sl@0: sl@0: These functions may fail if: sl@0: [EINVAL] The value specified by attrp is invalid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_init(posix_spawnattr_t* attrp) sl@0: @param attrp sl@0: @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. sl@0: sl@0: Initialize the spawn attributes structure. sl@0: 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. sl@0: sl@0: The posix_spawnattr_init() function shall fail if: sl@0: [ENOMEM] Insufficient memory exists to initialize the spawn attributes object. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setsigdefault(posix_spawnattr_t* attrp,const sigset_t* sigdefault) sl@0: @param attrp sl@0: @param sigdefault sl@0: @return Upon successful completion, posix_spawnattr_setsigdefault() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: The posix_spawnattr_setsigdefault() function shall set the spawn-sigdefault attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: The posix_spawnattr_setsigdefault() function may fail if: sl@0: [EINVAL] The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setflags(posix_spawnattr_t* attrp, short flags) sl@0: @param attrp sl@0: @param flags sl@0: @return Upon successful completion, posix_spawnattr_setflags() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: The posix_spawnattr_setflags() function shall set the spawn-flags attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: The posix_spawnattr_setflags() function may fail if: sl@0: [EINVAL] The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setpgroup(posix_spawnattr_t* attrp, pid_t pgroup) sl@0: @param attrp sl@0: @param pgroup sl@0: @return Upon successful completion, posix_spawnattr_setpgroup() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Sets the process group attribute sl@0: The posix_spawnattr_setpgroup() function shall set the spawn-pgroup attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: 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. sl@0: The posix_spawnattr_setpgroup() function may fail if: sl@0: [EINVAL]The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setschedparam(posix_spawnattr_t* attrp,const struct sched_param* schedparam) sl@0: @param attrp sl@0: @param schedparam sl@0: @return Upon successful completion, posix_spawnattr_setschedparam() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: Sets the scheduling parameters attribute. sl@0: The posix_spawnattr_setschedparam() function shall set the spawn-schedparam attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: The posix_spawnattr_setschedparam() function may fail if: sl@0: sl@0: EINVAL The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setschedpolicy(posix_spawnattr_t* attrp, int policy) sl@0: @param attrp sl@0: @param policy sl@0: @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: The posix_spawnattr_setschedpolicy() function shall set the spawn-schedpolicy attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: The posix_spawnattr_setschedpolicy() function may fail if: sl@0: EINVAL The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn posix_spawnattr_setsigmask(posix_spawnattr_t* attrp, const sigset_t* sigmask) sl@0: @param attrp sl@0: @param sigmask sl@0: @return @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error. sl@0: sl@0: sl@0: Sets the sigmask attribute. sl@0: The posix_spawnattr_setsigmask() function shall set the spawn-sigmask attribute in an initialized attributes object referenced by attrp. sl@0: sl@0: The posix_spawnattr_setsigmask() function may fail if: sl@0: sl@0: EINVAL The value of the attribute being set is not valid. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */