NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <sys/types.h> #include <spawn.h>int posix_spawn (pid_t *pid, const char *path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *attrp, char * const argv[], char * const envp[]);
The ChorusOS operating system currently has an incomplete implementation of posix spawn. Only the posix_spawn() and posix_spawnp() functions are available. The file_actions and attrp arguments must be NULL .
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The posix_spawn() and posix_spawnp() functions create a new process (child process) from a specified process image. The new process image is constructed from a regular executable file called the new process image file. When a C program is executed as a result of this call, it is entered as a C language function call as follows:
int main (int argc, char *argv[])
where argc is an argument count and argv is an array of character pointers to the arguments themselves. In addition, the variable extern char **environ is initialized as a pointer to an array of character pointers to the environment strings.
If a non- NULL PID is provided, the PID of the new process is returned on success.
The path argument to posix_spawn() is a pathname that identifies the new process image file to be executed.
The file parameter for posix_spawnp() is used to construct a pathname that identifies the new process image file. If the file parameter contains a slash character, the file parameter is used as the pathname for the new process image file. Otherwise, the path prefix for this file is obtained by searching the directories in the environment variable PATH . If this environment variable is not defined, the default path is searched.
A non- NULL file_actions argument provides a pointer to a structure that describes the open , close and dup actions performed on the child process before it starts running. When file_actions is NULL , no action is executed on the file descriptor set of the process.
This argument must be NULL in this version of the ChorusOS system.
When the attrp argument is NULL , the child process has the default attributes. When attrp is not NULL , the provided attribute values replace the default values.
This argument must be NULL in this version of the ChorusOS system.
The argument argv is an array of character pointers to null-terminated strings. The last member of this array is a NULL pointer and is not counted in argc . These strings constitute the argument list available to the new process image. The value in argv[0] should point to a filename that is associated with the process image being started by the posix_spawn() or posix_spawnp() functions.
The argument envp 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. The number of bytes available for the child process's combined argument and environment lists is { ARG_MAX }.
File descriptors opened during the calling process remain open in the child process, except for those whose close-on-exec flag FD_CLOEXEC is set. For those file descriptors that remain open, every attribute of the corresponding open file descriptions, including file locks, remains unchanged. If the file_actions argument is not NULL , the file actions are applied to this set of file descriptors.
The child process inherits the credentials of its parent, as well as the actor options, current directory and root directory (see acreate(2K) ).
Upon successful completion, the posix_spawn() and posix_spawnp() functions return the PID of the child process to the parent process, in the variable pointed to by a non- NULL pid argument, and return zero as the function return value. Otherwise, no child process is created, the value stored in the variable pointed to by a non- NULL pid is unspecified, and the corresponding error value is returned as the function return value.
The value of the errno variable is unspecified after a call to one of these functions. If the pid argument is the NULL pointer, the child's PID is not returned to the caller.
The value specified by file_action or attrp is invalid.
The path / file does not exist.
The system could not allocate enough memory.
An attempt was made to spawn a trusted child process from a non-trusted parent process.
The image file does not have execution permission.
Search permission is denied to a part of the path prefix.
The image file is not an ordinary file.
The image file is not an executable file.
The image file is not an ordinary file.
The number of bytes in the child process argument list is larger than ARG_MAX .
A component of the path prefix is not a directory.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
MT-Level | Async-Safe |
NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO