Unleashed v1.4
[unleashed.git] / share / man / man3c / posix_spawn_pipe_np.3c
blob244ed810a0eb2d1827956aedffc3a237456bb2b6
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
44 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
45 .\" Copyright 2011 by Delphix.  All rights reserved.
46 .\"
47 .TH POSIX_SPAWN_PIPE_NP 3C "Oct 14, 2011"
48 .SH NAME
49 posix_spawn_pipe_np \- spawn a process with connected pipe
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <spawn.h>
55 \fBint\fR \fBposix_spawn_pipe_np\fR(\fBpid_t *restrict\fR \fIpid\fR,
56      \fBint *restrict\fR \fIfdp\fR,
57      \fBconst char *restrict\fR \fIcmd\fR,
58      \fBboolean_t\fR \fIwrite\fR,
59      \fBconst posix_spawn_file_actions_t *\fR\fIfile_actions\fR,
60      \fBconst posix_spawnattr_t *restrict\fR \fIattr\fR);
61 .fi
63 .SH DESCRIPTION
64 .sp
65 .LP
66 The \fBposix_spawn_pipe_np()\fR function creates a new process
67 (child process) to run \fBsh -c \fIcmd\fR\fR, and connects the new
68 process's standard input or output to a file descriptor.
69 .sp
70 .LP
71 The new process's environment (the \fIenviron\fR global variable) is
72 inherited from the current process.
73 .sp
74 .LP
75 The \fIcmd\fR argument is the string for the child shell process to execute.
76 .sp
77 .LP
78 If the \fIwrite\fR argument is set, the returned file descriptor will be
79 connected to the new process's standard input, and will be opened for
80 writing.  Otherwise, the file descriptor will be connected to the new
81 process's standard output, and will be opened for reading.
82 .sp
83 .LP
84 If \fIfile_actions\fR is not \fINULL\fR, then the file descriptors open
85 in the child process are those open in the calling process as modified
86 by the spawn file actions object pointed to by \fIfile_actions\fR and
87 the \fBFD_CLOEXEC\fR flag of each remaining open file descriptor after
88 the spawn file actions have been processed.  See \fBposix_spawn\fR(3C)
89 for details on the behavior of \fIfile_actions\fR.
90 .sp
91 .LP
92 If \fIattr\fR is not \fINULL\fR, then the signal mask, signal default or
93 ignore actions, and the effective user and group IDs for the child
94 process are changed as specified in the attributes object referenced by
95 \fIattr\fR.  See \fBposix_spawn\fR(3C) for details on the behavior of
96 \fIattr\fR.
97 .sp
98 .LP
99 All process attributes, other than those influenced by the attributes set in
100 the object referenced by \fIattr\fR as specified above or by the file
101 descriptor manipulations specified in \fIfile_actions\fR appear in the new
102 process image as though \fBfork()\fR had been called to create a child process
103 and then a member of the \fBexec\fR family of functions had been called by the
104 child process to execute \fB/bin/sh\fR.
107 The fork handlers are not run when \fBposix_spawn_pipe_np()\fR is called.
108 .SH RETURN VALUES
111 Upon successful completion, \fBposix_spawn_pipe_np()\fR returns the
112 process ID of the child process to the parent process in the variable
113 pointed to by a non-null \fIpidp\fR argument, returns the file
114 descriptor which is connected to the child process in the variable
115 pointed to by a non-null \fIfdp\fR argument, and returns zero as the
116 function return value. Otherwise, no child process is created, the value
117 stored into the variable pointed to by a non-null \fIpidp\fR and
118 \fIfdp\fR is unspecified, and an error number is returned as the
119 function return value to indicate the error.
120 .SH ERRORS
123 See \fBposix_spawn\fR(3C).
125 .SH ATTRIBUTES
128 See \fBattributes\fR(5) for descriptions of the following attributes:
133 box;
134 c | c
135 l | l .
136 ATTRIBUTE TYPE  ATTRIBUTE VALUE
138 Interface Stability     Committed
140 MT-Level        MT-Safe
143 .SH SEE ALSO
146 \fBexec\fR(2), \fBfork\fR(2), \fBopen\fR(2),
147 \fBpopen\fR(3C), \fBposix_spawn\fR(3C),
148 \fBposix_spawn_file_actions_addclose\fR(3C),
149 \fBposix_spawn_file_actions_adddup2\fR(3C),
150 \fBposix_spawn_file_actions_addopen\fR(3C),
151 \fBposix_spawn_file_actions_destroy\fR(3C),
152 \fBposix_spawn_file_actions_init\fR(3C),
153 \fBposix_spawnattr_destroy\fR(3C),
154 \fBposix_spawnattr_getflags\fR(3C), \fBposix_spawnattr_getpgroup\fR(3C),
155 \fBposix_spawnattr_getschedparam\fR(3C),
156 \fBposix_spawnattr_getschedpolicy\fR(3C),
157 \fBposix_spawnattr_getsigdefault\fR(3C),
158 \fBposix_spawnattr_getsigignore_np\fR(3C),
159 \fBposix_spawnattr_getsigmask\fR(3C), \fBposix_spawnattr_init\fR(3C),
160 \fBposix_spawnattr_setflags\fR(3C), \fBposix_spawnattr_setpgroup\fR(3C),
161 \fBposix_spawnattr_setschedparam\fR(3C),
162 \fBposix_spawnattr_setschedpolicy\fR(3C),
163 \fBposix_spawnattr_setsigdefault\fR(3C),
164 \fBposix_spawnattr_setsigignore_np\fR(3C),
165 \fBposix_spawnattr_setsigmask\fR(3C),
166 \fBsystem\fR(3C), \fBwait\fR(3C),
167 \fBattributes\fR(5), \fBstandards\fR(5)