POSIX_SPAWN(3)

NAME
posix_spawn, posix_spawnp - spawn a process

SYNOPSIS

#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);

int posix_spawnp(pid_t *pid, const char *file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *attrp, char *const argv, char *const envp);

DESCRIPTION

Use posix_spawn and posix_spawnp to create a new child process from the specified process image file. argc is the argument count and argv is an array of argument strings passed to the new program. envp is an array of stings, which are passed as environment to the new program.

The path argument to posix_spawn identifies the new process image file to execute. The file argument to posix_spawnp is used to construct a pathname that identifies the new process image file by duplicating the actions of the shell in searching for an executable file if the specified filename does not contain a `/' character. The file is sought in the colon-separated list of directory pathnames specified in the PATH environment variable.

The file descriptors remain open across posix_spawn and posix_spawnp except for those marked as close-on-exec. The open file descriptors in the child process can be modified by the spawn file actions object pointed to by file_actions.

The spawn attributes object type pointed to by attrp argument may contain any of the attributes defined in spawn.h.

RETURNS

posix_spawn and posix_spawnp return the process ID of the newly spawned child process in the variable pointed by a non-NULL *pid argument and zero as the function return value upon successful completion. Otherwise, posix_spawn and posix_spawnp return an error number as the function return value to indicate the error; the value stored into the variable pointed to by a non-NULL *pid argument is unspecified.

PORTABILITY

POSIX.1-2008 requires posix_spawn and posix_spawnp.

Supporting OS subroutines required: _close, dup2, _fcntl, _execve, execvpe, _exit, _open, sigaction, sigprocmask, waitpid, sched_setscheduler, sched_setparam, setegid, seteuid, setpgid, vfork.

AUTHORS

Steve Chamberlain
    Author.

Roland Pesch
    Author.

Red Hat Support

Jeff Johnston
    Author.

COPYRIGHT

This file documents the ANSI C library.

Copyright (C) 1992, 1993, 1994-2014 Red Hat, Inc.

libc includes software developed by the University of California, Berkeley and its contributors.

libc includes software developed by Martin Jackson, Graham Haley and Steve Chamberlain of Tadpole Technology and released to Cygnus.

libc uses floating-point conversion software developed at AT&T, which includes this copyright information:

The author of this software is David M. Gay.

Copyright (c) 1991 by AT&T.

Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.

THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, subject to the terms of the GNU General Public License, which includes the provision that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.