|
NAMEposix_spawn , posix_spawnp
—
spawn a process
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <spawn.h>
int
int
DESCRIPTIONTheposix_spawn () and
posix_spawnp () functions create a new process (child
process) from the 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 the result of this call, it is entered as a C-language function call as follows: int main(int argc, char *argv[]); where argc is the argument count and argv is an array of character pointers to the arguments themselves. In addition, the variable: extern char **environ; points to an array of character pointers to the environment strings. 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
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 path argument to
The file parameter to
If file_actions is a null pointer, then file
descriptors open in the calling process remain open in the child process,
except for those whose close-on-exec flag If file_actions is not NULL, then the file
descriptors open in the child process are those open in the calling process
as modified by the spawn file actions object pointed to by
file_actions and the
The posix_spawnattr_t spawn attributes
object type is defined in
If the As a special case, if the
If the If the If the The The If the If the Signals set to be caught by the calling process are set to the default action in the child process. Signals set to be ignored by the calling process image are set to
be ignored by the child process, unless otherwise specified by the
If the value of the attrp pointer is NULL, then the default values are used. All process attributes, other than those influenced by the
attributes set in the object referenced by attrp as
specified above or by the file descriptor manipulations specified in
file_actions, appear in the new process image as
though The implementation uses RETURN VALUESUpon successful completion,posix_spawn () and
posix_spawnp () return the process ID 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, no value is stored into the
variable pointed to by pid, and an error number is
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.
ERRORS
SEE ALSOclose(2), dup2(2), execve(2), fcntl(2), open(2), sched_setparam(2), sched_setscheduler(2), setpgid(2), vfork(2), posix_spawn_file_actions_addclose(3), posix_spawn_file_actions_addclosefrom_np(3), posix_spawn_file_actions_adddup2(3), posix_spawn_file_actions_addopen(3), posix_spawn_file_actions_addchdir_np(3), posix_spawn_file_actions_addfchdir_np(3), posix_spawn_file_actions_destroy(3), posix_spawn_file_actions_init(3), posix_spawnattr_destroy(3), posix_spawnattr_getflags(3), posix_spawnattr_getpgroup(3), posix_spawnattr_getschedparam(3), posix_spawnattr_getschedpolicy(3), posix_spawnattr_getsigdefault(3), posix_spawnattr_getsigmask(3), posix_spawnattr_init(3), posix_spawnattr_setflags(3), posix_spawnattr_setpgroup(3), posix_spawnattr_setschedparam(3), posix_spawnattr_setschedpolicy(3), posix_spawnattr_setsigdefault(3), posix_spawnattr_setsigmask(3)STANDARDSTheposix_spawn () and
posix_spawnp () functions conform to
IEEE Std 1003.1-2001 (“POSIX.1”), except
that they ignore all errors from close (). A future
update of the Standard is expected to require that these functions not fail
because a file descriptor to be closed (via
posix_spawn_file_actions_addclose ()) is not open.
HISTORYTheposix_spawn () and
posix_spawnp () functions first appeared in
FreeBSD 8.0.
AUTHORSEd Schouten <ed@FreeBSD.org>
Visit the GSP FreeBSD Man Page Interface. |