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"
66 .Fn posix_spawn_file_actions_addclose
67 function adds a close operation to the list of operations associated with
68 the object referenced by
70 for subsequent use in a call to
74 The descriptor referred to by
78 had been called on it prior to the new child process
82 .Fn posix_spawn_file_actions_addopen
83 function adds an open operation to the list of operations associated with
84 the object referenced by
86 for subsequent use in a call to
90 The descriptor referred to by
99 had been called on it prior to the new child process
100 starting execution. The string
103 .Fn posix_spawn_file_actions_addopen
104 function during this process, so storage need not be persistent in the
108 .Fn posix_spawn_file_actions_adddup2
109 function adds a dup2 operation to the list of operations associated with
110 the object referenced by
112 for subsequent use in a call to
116 The descriptor referred to by
122 prior to the new child process starting execution.
125 .Fn posix_spawn_file_actions_addinherit_np
126 function adds an abstract inheritance operation to the
127 list of operations associated with the object referenced by
129 for subsequent use in a call to
133 The pre-existing descriptor referred to by
135 is marked for inheritance into the new process image, and the
137 flag is cleared from the file descriptor in the new process image.
143 all file descriptors are inherited from the parent process
144 into the spawned process, except for those explicitly
145 marked as close-on-exec. However if the flag
146 .Em POSIX_SPAWN_CLOEXEC_DEFAULT
147 is set, then during the spawn operation, all pre-existing
148 file descriptors in the parent process are treated as if they
149 had been marked close-on-exec i.e. none of them are automatically
151 .Xr posix_spawnattr_setflags 3 .
152 Only file descriptors explicitly manipulated via
154 are made available in the spawned process. In that case,
155 .Fn posix_spawn_file_actions_addinherit_np
156 can be used to make specific pre-existing file
157 descriptors from the parent process be
158 available in the spawned process.
160 On success, these functions return 0; on failure they return an error
164 These functions may fail if:
168 The value specified by
170 is negative or would cause the process to exceed the maximum number of
171 open files it is allowed.
179 Insufficient memory was available to add the new action to
185 .Xr posix_spawn_file_actions_init 3 ,
186 .Xr posix_spawn_file_actions_destroy 3 ,
187 .Xr posix_spawnattr_setflags 3 .
192 .Fn posix_spawn_file_actions_init
194 .Fn posix_spawn_file_actions_destroy
195 function calls appeared in