POSIX_SPAWN_PIPE_NP(3C) Standard C Library Functions POSIX_SPAWN_PIPE_NP(3C)

posix_spawn_pipe_np - spawn a process with connected pipe

#include <spawn.h>
int posix_spawn_pipe_np(pid_t *restrict pid,

int *restrict fdp,
const char *restrict cmd,
boolean_t write,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *restrict attr);

The posix_spawn_pipe_np() function creates a new process (child process) to run sh -c cmd, and connects the new process's standard input or output to a file descriptor.

The new process's environment (the environ global variable) is inherited from the current process.

The cmd argument is the string for the child shell process to execute.

If the write argument is set, the returned file descriptor will be connected to the new process's standard input, and will be opened for writing. Otherwise, the file descriptor will be connected to the new process's standard output, and will be opened for reading.

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 FD_CLOEXEC flag of each remaining open file descriptor after the spawn file actions have been processed. See posix_spawn(3C) for details on the behavior of file_actions.

If attr is not NULL, then the signal mask, signal default or ignore actions, and the effective user and group IDs for the child process are changed as specified in the attributes object referenced by attr. See posix_spawn(3C) for details on the behavior of attr.

All process attributes, other than those influenced by the attributes set in the object referenced by attr as specified above or by the file descriptor manipulations specified in file_actions appear in the new process image as though fork() had been called to create a child process and then a member of the exec family of functions had been called by the child process to execute /bin/sh.

The fork handlers are not run when posix_spawn_pipe_np() is called.

Upon successful completion, posix_spawn_pipe_np() returns the process ID of the child process to the parent process in the variable pointed to by a non-null pidp argument, returns the file descriptor which is connected to the child process in the variable pointed to by a non-null fdp argument, and returns zero as the function return value. Otherwise, no child process is created, the value stored into the variable pointed to by a non-null pidp and fdp is unspecified, and an error number is returned as the function return value to indicate the error.

See posix_spawn(3C).

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
MT-Level MT-Safe

exec(2), fork(2), open(2), popen(3C), posix_spawn(3C), posix_spawn_file_actions_addclose(3C), posix_spawn_file_actions_adddup2(3C), posix_spawn_file_actions_addopen(3C), posix_spawn_file_actions_destroy(3C), posix_spawn_file_actions_init(3C), posix_spawnattr_destroy(3C), posix_spawnattr_getflags(3C), posix_spawnattr_getpgroup(3C), posix_spawnattr_getschedparam(3C), posix_spawnattr_getschedpolicy(3C), posix_spawnattr_getsigdefault(3C), posix_spawnattr_getsigignore_np(3C), posix_spawnattr_getsigmask(3C), posix_spawnattr_init(3C), posix_spawnattr_setflags(3C), posix_spawnattr_setpgroup(3C), posix_spawnattr_setschedparam(3C), posix_spawnattr_setschedpolicy(3C), posix_spawnattr_setsigdefault(3C), posix_spawnattr_setsigignore_np(3C), posix_spawnattr_setsigmask(3C), system(3C), wait(3C), attributes(7), standards(7)

October 14, 2011 OmniOS