2 .\" Copyright (c) 2000-2010 Apple Inc. All rights reserved.
4 .\" @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 .\" This file contains Original Code and/or Modifications of Original Code
7 .\" as defined in and that are subject to the Apple Public Source License
8 .\" Version 2.0 (the 'License'). You may not use this file except in
9 .\" compliance with the License. The rights granted to you under the License
10 .\" may not be used to create, or enable the creation or redistribution of,
11 .\" unlawful or unlicensed copies of an Apple operating system, or to
12 .\" circumvent, violate, or enable the circumvention or violation of, any
13 .\" terms of an Apple operating system software license agreement.
15 .\" Please obtain a copy of the License at
16 .\" http://www.opensource.apple.com/apsl/ and read it before using this file.
18 .\" The Original Code and all software distributed under the License are
19 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 .\" Please see the License for the specific language governing rights and
24 .\" limitations under the License.
26 .\" @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 .\" @(#)posix_spawn_file_actions_addclose.3
31 .Dt POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE 3
34 .Nm posix_spawn_file_actions_addclose
35 .Nm posix_spawn_file_actions_addopen
36 .Nd add open or close actions to a
37 .Em posix_spawn_file_actions_t
39 .Fd #include <spawn.h>
41 .Fo posix_spawn_file_actions_addclose
42 .Fa "posix_spawn_file_actions_t *file_actions"
46 .Fo posix_spawn_file_actions_addopen
47 .Fa "posix_spawn_file_actions_t *restrict file_actions"
49 .Fa "const char *restrict path"
54 .Fo posix_spawn_file_actions_adddup2
55 .Fa "posix_spawn_file_actions_t *file_actions"
60 .Fo posix_spawn_file_actions_addinherit_np
61 .Fa "posix_spawn_file_actions_t *file_actions"
65 .Fo posix_spawn_file_actions_addchdir_np
66 .Fa "posix_spawn_file_actions_t *file_actions"
67 .Fa "const char *restrict path"
70 .Fo posix_spawn_file_actions_addfchdir_np
71 .Fa "posix_spawn_file_actions_t *file_actions"
76 .Fn posix_spawn_file_actions_addclose
77 function adds a close operation to the list of operations associated with
78 the object referenced by
80 for subsequent use in a call to
84 The descriptor referred to by
88 had been called on it prior to the new child process
92 .Fn posix_spawn_file_actions_addopen
93 function adds an open operation to the list of operations associated with
94 the object referenced by
96 for subsequent use in a call to
100 The descriptor referred to by
109 had been called on it prior to the new child process
110 starting execution. The string
113 .Fn posix_spawn_file_actions_addopen
114 function during this process, so storage need not be persistent in the
118 .Fn posix_spawn_file_actions_adddup2
119 function adds a dup2 operation to the list of operations associated with
120 the object referenced by
122 for subsequent use in a call to
126 The descriptor referred to by
132 prior to the new child process starting execution.
135 .Fn posix_spawn_file_actions_addinherit_np
136 function adds an abstract inheritance operation to the
137 list of operations associated with the object referenced by
139 for subsequent use in a call to
143 The pre-existing descriptor referred to by
145 is marked for inheritance into the new process image, and the
147 flag is cleared from the file descriptor in the new process image.
153 all file descriptors are inherited from the parent process
154 into the spawned process, except for those explicitly
155 marked as close-on-exec. However if the flag
156 .Em POSIX_SPAWN_CLOEXEC_DEFAULT
157 is set, then during the spawn operation, all pre-existing
158 file descriptors in the parent process are treated as if they
159 had been marked close-on-exec i.e. none of them are automatically
161 .Xr posix_spawnattr_setflags 3 .
162 Only file descriptors explicitly manipulated via
164 are made available in the spawned process. In that case,
165 .Fn posix_spawn_file_actions_addinherit_np
166 can be used to make specific pre-existing file
167 descriptors from the parent process be
168 available in the spawned process.
171 .Fn posix_spawn_file_actions_addchdir
172 function adds an chdir operation to the list of operations associated with
173 the object referenced by
175 for subsequent use in a call to
179 The current working directory will be set as if
183 prior to the new child process starting execution.
186 .Fn posix_spawn_file_actions_addfchdir
187 function adds a fchdir operation to the list of operations associated with
188 the object referenced by
190 for subsequent use in a call to
194 The current working directory will be set as if
198 prior to the new child process starting execution.
200 .Em POSIX_SPAWN_CLOEXEC_DEFAULT
201 is set, the file descriptor
203 will not be automatically inherited unless an explicit
204 .Fn posix_spawn_file_actions_addinherit_np
209 On success, these functions return 0; on failure they return an error
213 These functions may fail if:
217 The value specified by
219 is negative or would cause the process to exceed the maximum number of
220 open files it is allowed.
227 .It Bq Er ENAMETOOLONG
228 The length of the value specified by
234 Insufficient memory was available to add the new action to
240 .Xr posix_spawn_file_actions_init 3 ,
241 .Xr posix_spawn_file_actions_destroy 3 ,
242 .Xr posix_spawnattr_setflags 3 .
247 .Fn posix_spawn_file_actions_init
249 .Fn posix_spawn_file_actions_destroy
250 function calls appeared in