xref: /titanic_44/usr/src/man/man3c/posix_spawn_pipe_np.3c (revision 91d7f85e02991954d1e1bd44673df567ad8dcc87)
te
Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
Copyright 2011 by Delphix. All rights reserved.
POSIX_SPAWN_PIPE_NP 3C "Oct 14, 2011"
NAME
posix_spawn_pipe_np - spawn a process with connected pipe
SYNOPSIS

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

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.

RETURN VALUES

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.

ERRORS

See posix_spawn(3C).

ATTRIBUTES

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

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

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(5), standards(5)