1POSIX_SPAWN_FILE_ACTIONS_ADDPDOUSPI2X(3PPr)ogrammerP'OsSIMXa_nSuPaAlWN_FILE_ACTIONS_ADDDUP2(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 posix_spawn_file_actions_adddup2 — add dup2 action to spawn file
14 actions object (ADVANCED REALTIME)
15
17 #include <spawn.h>
18
19 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t
20 *file_actions, int fildes, int newfildes);
21
23 The posix_spawn_file_actions_adddup2() function shall add a dup2()
24 action to the object referenced by file_actions that shall cause the
25 file descriptor fildes to be duplicated as newfildes (as if
26 dup2(fildes, newfildes) had been called) when a new process is spawned
27 using this file actions object.
28
29 A spawn file actions object is as defined in
30 posix_spawn_file_actions_addclose().
31
33 Upon successful completion, the posix_spawn_file_actions_adddup2()
34 function shall return zero; otherwise, an error number shall be
35 returned to indicate the error.
36
38 The posix_spawn_file_actions_adddup2() function shall fail if:
39
40 EBADF The value specified by fildes or newfildes is negative or
41 greater than or equal to {OPEN_MAX}.
42
43 ENOMEM Insufficient memory exists to add to the spawn file actions
44 object.
45
46 The posix_spawn_file_actions_adddup2() function may fail if:
47
48 EINVAL The value specified by file_actions is invalid.
49
50 It shall not be considered an error for the fildes argument passed to
51 the posix_spawn_file_actions_adddup2() function to specify a file
52 descriptor for which the specified operation could not be performed at
53 the time of the call. Any such error will be detected when the associ‐
54 ated file actions object is later used during a posix_spawn() or
55 posix_spawnp() operation.
56
57 The following sections are informative.
58
60 None.
61
63 The posix_spawn_file_actions_adddup2() function is part of the Spawn
64 option and need not be provided on all implementations.
65
66 Implementations may use file descriptors that must be inherited into
67 child processes for the child process to remain conforming, such as for
68 message catalog or tracing purposes. Therefore, an application that
69 calls posix_spawn_file_actions_adddup2() with an arbitrary integer for
70 newfildes risks non-conforming behavior, and this function can only
71 portably be used to overwrite file descriptor values that the applica‐
72 tion has obtained through explicit actions, or for the three file
73 descriptors corresponding to the standard file streams. In order to
74 avoid a race condition of leaking an unintended file descriptor into a
75 child process, an application should consider opening all file descrip‐
76 tors with the FD_CLOEXEC bit set unless the file descriptor is intended
77 to be inherited across exec.
78
80 Refer to the RATIONALE section in posix_spawn_file_actions_addclose().
81
83 None.
84
86 dup(), posix_spawn(), posix_spawn_file_actions_addclose(),
87 posix_spawn_file_actions_destroy()
88
89 The Base Definitions volume of POSIX.1‐2008, <spawn.h>
90
92 Portions of this text are reprinted and reproduced in electronic form
93 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
94 -- Portable Operating System Interface (POSIX), The Open Group Base
95 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
96 cal and Electronics Engineers, Inc and The Open Group. (This is
97 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
98 event of any discrepancy between this version and the original IEEE and
99 The Open Group Standard, the original IEEE and The Open Group Standard
100 is the referee document. The original Standard can be obtained online
101 at http://www.unix.org/online.html .
102
103 Any typographical or formatting errors that appear in this page are
104 most likely to have been introduced during the conversion of the source
105 files to man page format. To report such errors, see https://www.ker‐
106 nel.org/doc/man-pages/reporting_bugs.html .
107
108
109
110IEEE/The Open Group 2013 POSIX_SPAWN_FILE_ACTIONS_ADDDUP2(3P)