1 .\" $NetBSD: posix_spawn_file_actions_addopen.3,v 1.3 2013/07/20 21:39:57 wiz Exp $
3 .\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" Portions of this text are reprinted and reproduced in electronic form
28 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
29 .\" Portable Operating System Interface (POSIX), The Open Group Base
30 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
31 .\" Electrical and Electronics Engineers, Inc and The Open Group. In the
32 .\" event of any discrepancy between this version and the original IEEE and
33 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
34 .\" the referee document. The original Standard can be obtained online at
35 .\" http://www.opengroup.org/unix/online.html.
37 .\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_addopen.3,v 1.2.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $
40 .Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3
43 .Nm posix_spawn_file_actions_addopen ,
44 .Nm posix_spawn_file_actions_adddup2 ,
45 .Nm posix_spawn_file_actions_addclose
46 .Nd "add open, dup2 or close action to spawn file actions object"
52 .Fn posix_spawn_file_actions_addopen "posix_spawn_file_actions_t * file_actions" "int fildes" "const char *restrict path" "int oflag" "mode_t mode"
54 .Fn posix_spawn_file_actions_adddup2 "posix_spawn_file_actions_t * file_actions" "int fildes" "int newfildes"
56 .Fn posix_spawn_file_actions_addclose "posix_spawn_file_actions_t * file_actions" "int fildes"
58 These functions add an open, dup2 or close action to a spawn
61 A spawn file actions object is of type
62 .Vt posix_spawn_file_actions_t
65 and is used to specify a series of actions to be performed by a
69 operation in order to arrive at the set of open file descriptors for the
70 child process given the set of open file descriptors of the parent.
72 A spawn file actions object, when passed to
76 specify how the set of open file descriptors in the calling
77 process is transformed into a set of potentially open file descriptors
78 for the spawned process.
79 This transformation is as if the specified sequence of actions was
80 performed exactly once, in the context of the spawned process (prior to
81 execution of the new process image), in the order in which the actions
82 were added to the object; additionally, when the new process image is
83 executed, any file descriptor (from this new set) which has its
85 flag set is closed (see
89 .Fn posix_spawn_file_actions_addopen
90 function adds an open action to the object referenced by
92 that causes the file named by
95 .Bd -literal -offset indent
96 open(path, oflag, mode)
99 had been called, and the returned file descriptor, if not
103 when a new process is spawned using this file actions object.
106 was already an open file descriptor, it is closed before the new
109 The string described by
112 .Fn posix_spawn_file_actions_addopen
116 .Fn posix_spawn_file_actions_adddup2
117 function adds a dup2 action to the object referenced by
119 that causes the file descriptor
124 .Bd -literal -offset indent
125 dup2(fildes, newfildes)
128 had been called) when a new process is spawned using this file actions object.
131 .Fn posix_spawn_file_actions_addclose
132 function adds a close action to the object referenced by
134 that causes the file descriptor
137 .Bd -literal -offset indent
141 had been called) when a new process is spawned using this file actions
144 Upon successful completion, these functions return zero;
145 otherwise, an error number is returned to indicate the error.
151 The value specified by
157 Insufficient memory exists to add to the spawn file actions object.
164 .Xr posix_spawn_file_actions_destroy 3 ,
165 .Xr posix_spawn_file_actions_init 3 ,
169 .Fn posix_spawn_file_actions_addopen ,
170 .Fn posix_spawn_file_actions_adddup2
172 .Fn posix_spawn_file_actions_addclose
177 .Fn posix_spawn_file_actions_addopen ,
178 .Fn posix_spawn_file_actions_adddup2
180 .Fn posix_spawn_file_actions_addclose
181 functions first appeared in
186 .An Ed Schouten Aq Mt ed@FreeBSD.org