1951 leaking a vdev when removing an l2cache device
[unleashed.git] / usr / src / man / man3c / posix_spawn_file_actions_addclose.3c
blobe5c662ee314a25b1b449413850852903c95e563e
1 '\" te
2 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
3 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
4 .\" 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/.
5 .\" 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
6 .\" 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
7 .\" 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.
8 .\"  This notice shall appear on any product containing this material.
9 .\" 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.
10 .\" 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.
11 .\" 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]
12 .TH POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE 3C "Feb 20, 2009"
13 .SH NAME
14 posix_spawn_file_actions_addclose, posix_spawn_file_actions_addopen \- add
15 close or open action to spawn file actions object
16 .SH SYNOPSIS
17 .LP
18 .nf
19 #include <spawn.h>
21 \fBint\fR \fBposix_spawn_file_actions_addclose\fR(
22      \fBposix_spawn_file_actions_t *\fR\fIfile_actions\fR, \fBint\fR \fIfildes\fR);
23 .fi
25 .LP
26 .nf
27 \fBint\fR \fBposix_spawn_file_actions_addopen\fR(
28      \fBposix_spawn_file_actions_t *restrict\fR \fIfile_actions\fR, \fBint\fR \fIfildes\fR,
29      \fBconst char *restrict\fR \fIpath\fR, \fBint\fR \fIoflag\fR, \fBmode_t\fR \fImode\fR);
30 .fi
32 .SH DESCRIPTION
33 .sp
34 .LP
35 These functions add or delete a close or open action to a spawn file actions
36 object.
37 .sp
38 .LP
39 A spawn file actions object is of type \fBposix_spawn_file_actions_t\fR
40 (defined in <\fBspawn.h\fR>) and is used to specify a series of actions to be
41 performed by a \fBposix_spawn\fR(3C) or \fBposix_spawn\fR(3C) operation to
42 arrive at the set of open file descriptors for the child process given the set
43 of open file descriptors of the parent.
44 .sp
45 .LP
46 A spawn file actions object, when passed to \fBposix_spawn()\fR or
47 \fBposix_spawnp()\fR, specifies how the set of open file descriptors in the
48 calling process is transformed into a set of potentially open file descriptors
49 for the spawned process. This transformation occurs as though the specified
50 sequence of actions was performed exactly once, in the context of the spawned
51 process (prior to execution of the new process image), in the order in which
52 the actions were added to the object.  Additionally, when the new process image
53 is executed, any file descriptor (from this new set) which has its
54 \fBFD_CLOEXEC\fR flag set is closed (see \fBposix_spawn\fR(3C)).
55 .sp
56 .LP
57 The \fBposix_spawn_file_actions_addclose()\fR function adds a close action to
58 the object referenced by \fIfile_actions\fR that causes the file descriptor
59 fildes to be closed (as if \fBclose\fR(\fIfildes\fR) had been called) when a
60 new process is spawned using this file actions object.
61 .sp
62 .LP
63 The \fBposix_spawn_file_actions_addopen()\fR function adds an open action to
64 the object referenced by \fIfile_actions\fR that causes the file named by path
65 to be opened (as if \fBopen\fR(\fIpath\fR, \fIoflag\fR, \fImode\fR) had been
66 called, and the returned file descriptor, if not \fIfildes\fR, had been changed
67 to \fIfildes\fR) when a new process is spawned using this file actions object.
68 If \fIfildes\fR was already an open file descriptor, it is closed before the
69 new file is opened.
70 .sp
71 .LP
72 The string described by \fIpath\fR is copied by the
73 \fBposix_spawn_file_actions_addopen()\fR function.
74 .SH RETURN VALUES
75 .sp
76 .LP
77 Upon successful completion, these functions return 0. Otherwise, an error
78 number is returned to indicate the error.
79 .SH ERRORS
80 .sp
81 .LP
82 These functions will fail if:
83 .sp
84 .ne 2
85 .na
86 \fB\fBEBADF\fR\fR
87 .ad
88 .RS 9n
89 The value specified by \fIfildes\fR is negative or greater than or equal to
90 {\fBOPEN_MAX\fR}.
91 .RE
93 .sp
94 .LP
95 These functions may fail if:
96 .sp
97 .ne 2
98 .na
99 \fB\fBEINVAL\fR\fR
101 .RS 10n
102 The value specified by \fIfile_actions\fR is invalid.
106 .ne 2
108 \fB\fBENOMEM\fR\fR
110 .RS 10n
111 Insufficient memory exists to add to the spawn file actions object.
116 It is not considered an error for the \fIfildes\fR argument passed to these
117 functions to specify a file descriptor for which the specified operation could
118 not be performed at the time of the call. Any such error will be detected when
119 the associated file actions object is later used during a \fBposix_spawn()\fR
120 or \fBposix_spawnp()\fR operation.
123 If a \fBclose\fR(2) operation is specified for a file descriptor that is not
124 open at the time of the call to \fBposix_spawn()\fR or \fBposix_spawnp()\fR,
125 the close operation will not cause the \fBposix_spawn()\fR or
126 \fBposix_spawnp()\fR operation to fail.
127 .SH ATTRIBUTES
130 See \fBattributes\fR(5) for descriptions of the following attributes:
135 box;
136 c | c
137 l | l .
138 ATTRIBUTE TYPE  ATTRIBUTE VALUE
140 Interface Stability     Committed
142 MT-Level        MT-Safe
144 Standard        See \fBstandards\fR(5).
147 .SH SEE ALSO
150 \fBclose\fR(2), \fBdup\fR(2), \fBopen\fR(2), \fBposix_spawn\fR(3C),
151 \fBposix_spawn_file_actions_adddup2\fR(3C),
152 \fBposix_spawn_file_actions_destroy\fR(3C), \fBattributes\fR(5),
153 \fBstandards\fR(5)