os/ossrv/genericopenlibs/openenvcore/include/spawn.dosc
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /** @file  ../include/spawn.h
     2 @internalComponent
     3 */
     4 
     5 /** @def POSIX_SPAWN_RESETIDS
     6 
     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.
    10 
    11 @publishedAll
    12 @externallyDefinedApi
    13 */
    14 
    15 /** @def POSIX_SPAWN_SETPGROUP
    16 
    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.
    20 
    21 @publishedAll
    22 @externallyDefinedApi
    23 */
    24 
    25 /** @def POSIX_SPAWN_SETSIGDEF
    26 
    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.
    30 
    31 @publishedAll
    32 @externallyDefinedApi
    33 */
    34 
    35 /** @def POSIX_SPAWN_SETSIGMASK
    36 
    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.
    39 
    40 @publishedAll
    41 @externallyDefinedApi
    42 */
    43 
    44 /** @def POSIX_SPAWN_SETSCHEDPARAM
    45 
    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.
    48 
    49 @publishedAll
    50 @externallyDefinedApi
    51 */
    52 
    53 /** @def POSIX_SPAWN_SETSCHEDULER
    54 
    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.
    57 
    58 @publishedAll
    59 @externallyDefinedApi
    60 */
    61 
    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)
    63 @param aPid
    64 @param aFile
    65 @param aFileActions
    66 @param attrp
    67 @param aArgs
    68 @param 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.
    70 
    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.
    72 
    73 Note: When a child process created using posix_spawn() exits, the parent process receives a SIGCHLD signal.
    74 
    75 @code
    76 
    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.
    82 
    83 @endcode
    84   
    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.
    86 
    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.
    89 
    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.
    91 
    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:
    93 
    94 @code
    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.
    99 @endcode
   100 
   101 The posix_spawn() and posix_spawnp() functions may fail if:
   102 
   103 [EINVAL] The value specified by file_actions or attrp is invalid. 
   104 
   105 @publishedAll
   106 @externallyDefinedApi
   107 */
   108 
   109 /** @fn  posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* file_actions, int fid)
   110 @param file_actions
   111 @param fid
   112 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
   113 
   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.
   116 
   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:
   119 
   120 @code
   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. 
   125 @encode
   126 
   127 @publishedAll
   128 @externallyDefinedApi
   129 */
   130 
   131 /** @fn  posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* file_actions, int fid1,int fid2)
   132 @param file_actions
   133 @param fid1
   134 @param 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.
   136 
   137 Add a dup2 action to the file actions structure
   138 
   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.
   140 
   141 @code
   142 The posix_spawn_file_actions_adddup2() function shall fail if:
   143 
   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. 
   148 @encode
   149 
   150 @publishedAll
   151 @externallyDefinedApi
   152 */
   153 
   154 /** @fn  posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* file_actions, int fid,const char* path, int oflag, mode_t mode)
   155 @param file_actions
   156 @param fid
   157 @param path
   158 @param oflag
   159 @param mode
   160 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
   161 
   162 Add an open action to the file actions structure
   163 
   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.
   166 
   167 @code
   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. 
   173 @encode
   174 
   175 @publishedAll
   176 @externallyDefinedApi
   177 */
   178 
   179 /** @fn  posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* file_actions)
   180 @param file_actions
   181 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
   182 
   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.
   185 
   186 @publishedAll
   187 @externallyDefinedApi
   188 */
   189 
   190 /** @fn  posix_spawn_file_actions_init(posix_spawn_file_actions_t* file_actions)
   191 @param file_actions
   192 @return Upon successful completion, these functions shall return zero; otherwise, an error number shall be returned to indicate the error.
   193 
   194 Initialize the file actions structure.
   195 
   196 The posix_spawn_file_actions_init() function shall fail if:
   197 [ENOMEM] Insufficient memory exists to initialize the spawn file actions object. 
   198 
   199 @publishedAll
   200 @externallyDefinedApi
   201 */
   202 
   203 /** @fn  posix_spawnattr_destroy(posix_spawnattr_t* attrp)
   204 @param attrp
   205 @return Returns 0
   206 
   207 Empty and cleanup the spawn attributes structure
   208 
   209 @publishedAll
   210 @externallyDefinedApi
   211 */
   212 
   213 /** @fn  posix_spawnattr_getsigdefault(const posix_spawnattr_t* attrp, sigset_t* sigdefault)
   214 @param attrp
   215 @param sigdefault
   216 @return Returns the sigdefault attribute
   217 
   218 The posix_spawnattr_getsigdefault() function shall obtain the value of the spawn-sigdefault attribute from the attributes object referenced by attrp.
   219 
   220 @publishedAll
   221 @externallyDefinedApi
   222 */
   223 
   224 /** @fn  posix_spawnattr_getflags(const posix_spawnattr_t* attrp,short* flags)
   225 @param attrp
   226 @param flags
   227 @return Return the flags attribute
   228 
   229 The posix_spawnattr_getflags() function shall obtain the value of the spawn-flags attribute from the attributes object referenced by attrp.
   230 
   231 These functions may fail if:
   232 [EINVAL] The value specified by attrp is invalid. 
   233 
   234 @publishedAll
   235 @externallyDefinedApi
   236 */
   237 
   238 /** @fn  posix_spawnattr_getpgroup(const posix_spawnattr_t* attrp, pid_t* pgroup)
   239 @param attrp
   240 @param pgroup
   241 @return Return the process group attribute
   242 
   243 The posix_spawnattr_getpgroup() function shall obtain the value of the spawn-pgroup attribute from the attributes object referenced by attrp.
   244 
   245 These functions may fail if:
   246 [EINVAL] The value specified by attrp is invalid. 
   247 
   248 @publishedAll
   249 @externallyDefinedApi
   250 */
   251 
   252 /** @fn  posix_spawnattr_getschedparam(const posix_spawnattr_t* attrp,struct sched_param* schedparam)
   253 @param attrp
   254 @param schedparam
   255 @return Return scheduling parameters attribute
   256 
   257 The posix_spawnattr_getschedparam() function shall obtain the value of the spawn-schedparam attribute from the attributes object referenced by attrp.
   258 
   259 These functions may fail if:
   260 [EINVAL] The value specified by attrp is invalid. 
   261 
   262 @publishedAll
   263 @externallyDefinedApi
   264 */
   265 
   266 /** @fn  posix_spawnattr_getschedpolicy(const posix_spawnattr_t* attrp, int* policy)
   267 @param attrp
   268 @param policy
   269 @return Return the scheduling policy attribute
   270 
   271 The posix_spawnattr_getschedpolicy() function shall obtain the value of the spawn-schedpolicy attribute from the attributes object referenced by attrp.
   272 
   273 These functions may fail if:
   274 [EINVAL] The value specified by attrp is invalid. 
   275 
   276 @publishedAll
   277 @externallyDefinedApi
   278 */
   279 
   280 /** @fn  posix_spawnattr_getsigmask(const posix_spawnattr_t* attrp, sigset_t* sigmask)
   281 @param attrp
   282 @param sigmask
   283 @return Return the signal mask attribute
   284 
   285 The posix_spawnattr_getsigmask() function shall obtain the value of the spawn-sigmask attribute from the attributes object referenced by attrp.
   286 
   287 These functions may fail if:
   288 [EINVAL] The value specified by attrp is invalid. 
   289 
   290 @publishedAll
   291 @externallyDefinedApi
   292 */
   293 
   294 /** @fn  posix_spawnattr_init(posix_spawnattr_t* attrp)
   295 @param 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.
   297 
   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.
   300 
   301 The posix_spawnattr_init() function shall fail if:
   302 [ENOMEM]  Insufficient memory exists to initialize the spawn attributes object. 
   303 
   304 @publishedAll
   305 @externallyDefinedApi
   306 */
   307 
   308 /** @fn  posix_spawnattr_setsigdefault(posix_spawnattr_t* attrp,const sigset_t* sigdefault)
   309 @param attrp
   310 @param sigdefault
   311 @return Upon successful completion, posix_spawnattr_setsigdefault() shall return zero; otherwise, an error number shall be returned to indicate the error.
   312 
   313 The posix_spawnattr_setsigdefault() function shall set the spawn-sigdefault attribute in an initialized attributes object referenced by attrp.
   314 
   315 The posix_spawnattr_setsigdefault() function may fail if:
   316 [EINVAL] The value of the attribute being set is not valid. 
   317 
   318 @publishedAll
   319 @externallyDefinedApi
   320 */
   321 
   322 /** @fn  posix_spawnattr_setflags(posix_spawnattr_t* attrp, short flags)
   323 @param attrp
   324 @param flags
   325 @return Upon successful completion, posix_spawnattr_setflags() shall return zero; otherwise, an error number shall be returned to indicate the error.
   326 
   327 The posix_spawnattr_setflags() function shall set the spawn-flags attribute in an initialized attributes object referenced by attrp.
   328 
   329 The posix_spawnattr_setflags() function may fail if:
   330 [EINVAL]  The value of the attribute being set is not valid. 
   331 
   332 @publishedAll
   333 @externallyDefinedApi
   334 */
   335 
   336 /** @fn  posix_spawnattr_setpgroup(posix_spawnattr_t* attrp, pid_t pgroup)
   337 @param attrp
   338 @param pgroup
   339 @return Upon successful completion, posix_spawnattr_setpgroup() shall return zero; otherwise, an error number shall be returned to indicate the error.
   340 
   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.
   343 
   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. 
   347 
   348 @publishedAll
   349 @externallyDefinedApi
   350 */
   351 
   352 /** @fn  posix_spawnattr_setschedparam(posix_spawnattr_t* attrp,const struct sched_param* schedparam)
   353 @param attrp
   354 @param schedparam
   355 @return Upon successful completion, posix_spawnattr_setschedparam() shall return zero; otherwise, an error number shall be returned to indicate the error.
   356 
   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.
   359 
   360 The posix_spawnattr_setschedparam() function may fail if:
   361 
   362 EINVAL The value of the attribute being set is not valid.
   363 
   364 @publishedAll
   365 @externallyDefinedApi
   366 */
   367 
   368 /** @fn  posix_spawnattr_setschedpolicy(posix_spawnattr_t* attrp, int policy)
   369 @param attrp
   370 @param policy
   371 @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error.
   372 
   373 The posix_spawnattr_setschedpolicy() function shall set the spawn-schedpolicy attribute in an initialized attributes object referenced by attrp.
   374 
   375 The posix_spawnattr_setschedpolicy() function may fail if:
   376 EINVAL The value of the attribute being set is not valid.
   377 
   378 @publishedAll
   379 @externallyDefinedApi
   380 */
   381 
   382 /** @fn  posix_spawnattr_setsigmask(posix_spawnattr_t* attrp, const sigset_t* sigmask)
   383 @param attrp
   384 @param sigmask
   385 @return @return Upon successful completion, posix_spawnattr_setschedpolicy() shall return zero; otherwise, an error number shall be returned to indicate the error.
   386 
   387 
   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.
   390 
   391 The posix_spawnattr_setsigmask() function may fail if:
   392 
   393 EINVAL The value of the attribute being set is not valid.
   394 
   395 @publishedAll
   396 @externallyDefinedApi
   397 */