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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
43 .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
44 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
46 .TH POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE 3C "Feb 20, 2009"
48 posix_spawn_file_actions_addclose, posix_spawn_file_actions_addopen \- add
49 close or open action to spawn file actions object
55 \fBint\fR \fBposix_spawn_file_actions_addclose\fR(
56 \fBposix_spawn_file_actions_t *\fR\fIfile_actions\fR, \fBint\fR \fIfildes\fR);
61 \fBint\fR \fBposix_spawn_file_actions_addopen\fR(
62 \fBposix_spawn_file_actions_t *restrict\fR \fIfile_actions\fR, \fBint\fR \fIfildes\fR,
63 \fBconst char *restrict\fR \fIpath\fR, \fBint\fR \fIoflag\fR, \fBmode_t\fR \fImode\fR);
69 These functions add or delete a close or open action to a spawn file actions
73 A spawn file actions object is of type \fBposix_spawn_file_actions_t\fR
74 (defined in <\fBspawn.h\fR>) and is used to specify a series of actions to be
75 performed by a \fBposix_spawn\fR(3C) or \fBposix_spawn\fR(3C) operation to
76 arrive at the set of open file descriptors for the child process given the set
77 of open file descriptors of the parent.
80 A spawn file actions object, when passed to \fBposix_spawn()\fR or
81 \fBposix_spawnp()\fR, specifies how the set of open file descriptors in the
82 calling process is transformed into a set of potentially open file descriptors
83 for the spawned process. This transformation occurs as though the specified
84 sequence of actions was performed exactly once, in the context of the spawned
85 process (prior to execution of the new process image), in the order in which
86 the actions were added to the object. Additionally, when the new process image
87 is executed, any file descriptor (from this new set) which has its
88 \fBFD_CLOEXEC\fR flag set is closed (see \fBposix_spawn\fR(3C)).
91 The \fBposix_spawn_file_actions_addclose()\fR function adds a close action to
92 the object referenced by \fIfile_actions\fR that causes the file descriptor
93 fildes to be closed (as if \fBclose\fR(\fIfildes\fR) had been called) when a
94 new process is spawned using this file actions object.
97 The \fBposix_spawn_file_actions_addopen()\fR function adds an open action to
98 the object referenced by \fIfile_actions\fR that causes the file named by path
99 to be opened (as if \fBopen\fR(\fIpath\fR, \fIoflag\fR, \fImode\fR) had been
100 called, and the returned file descriptor, if not \fIfildes\fR, had been changed
101 to \fIfildes\fR) when a new process is spawned using this file actions object.
102 If \fIfildes\fR was already an open file descriptor, it is closed before the
106 The string described by \fIpath\fR is copied by the
107 \fBposix_spawn_file_actions_addopen()\fR function.
111 Upon successful completion, these functions return 0. Otherwise, an error
112 number is returned to indicate the error.
116 These functions will fail if:
123 The value specified by \fIfildes\fR is negative or greater than or equal to
129 These functions may fail if:
136 The value specified by \fIfile_actions\fR is invalid.
145 Insufficient memory exists to add to the spawn file actions object.
150 It is not considered an error for the \fIfildes\fR argument passed to these
151 functions to specify a file descriptor for which the specified operation could
152 not be performed at the time of the call. Any such error will be detected when
153 the associated file actions object is later used during a \fBposix_spawn()\fR
154 or \fBposix_spawnp()\fR operation.
157 If a \fBclose\fR(2) operation is specified for a file descriptor that is not
158 open at the time of the call to \fBposix_spawn()\fR or \fBposix_spawnp()\fR,
159 the close operation will not cause the \fBposix_spawn()\fR or
160 \fBposix_spawnp()\fR operation to fail.
164 See \fBattributes\fR(5) for descriptions of the following attributes:
172 ATTRIBUTE TYPE ATTRIBUTE VALUE
174 Interface Stability Committed
178 Standard See \fBstandards\fR(5).
184 \fBclose\fR(2), \fBdup\fR(2), \fBopen\fR(2), \fBposix_spawn\fR(3C),
185 \fBposix_spawn_file_actions_adddup2\fR(3C),
186 \fBposix_spawn_file_actions_destroy\fR(3C), \fBattributes\fR(5),