POSIX_S...ADDDUP2(3POSIX)
π PROLOG π
okay so bestie, quick heads up before we dive in: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not be implemented on Linux at all. π
β¨ NAME β¨
posix_spawn_file_actions_adddup2 β add dup2 action to spawn file actions object (ADVANCED REALTIME) π¦
πΈ SYNOPSIS πΈ
#include <spawn.h>
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t
*file_actions, int fildes, int newfildes);
π DESCRIPTION π
so the posix_spawn_file_actions_adddup2() function shall add a dup2() action to the object referenced by file_actions, and that action shall cause the file descriptor fildes to be duplicated as newfildes β literally as if dup2(fildes, newfildes) had been called β at the moment a new process gets spawned using this file actions object. slay. π
and a spawn file actions object is as defined in posix_spawn_file_actions_addclose(), iykyk. β¨
π RETURN VALUE π
upon successful completion, posix_spawn_file_actions_adddup2() shall return zero; otherwise, an error number shall be returned to indicate the error. that's it, that's the vibe. π«Ά
π₯ ERRORS π₯
the posix_spawn_file_actions_adddup2() function shall fail if:
EBADFβ the value specified byfildesornewfildesis negative or greater than or equal to{OPEN_MAX}. πENOMEMβ insufficient memory exists to add to the spawn file actions object. no memory, no action, periodt.
the posix_spawn_file_actions_adddup2() function may fail if:
EINVALβ the value specified byfile_actionsis invalid. π
okay this part is important bestie: it shall not be considered an error for thefildesargument passed toposix_spawn_file_actions_adddup2()to specify a file descriptor for which the specified operation could not be performed at the time of the call. any such error will be detected later, when the associated file actions object is used during aposix_spawn()orposix_spawnp()operation. so like, it's giving "we'll deal with it when we get there". π
the following sections are informative.
π EXAMPLES π
None. β yeah bestie there's literally nothing here. iconic in its emptiness tbh. π
π§ APPLICATION USAGE π§
posix_spawn_file_actions_adddup2() is part of the Spawn option and need not be provided on all implementations, so don't come for me if your platform said no. π
implementations may use file descriptors that must be inherited into child processes for the child process to remain conforming β like for message catalog or tracing purposes, lowkey important stuff. so therefore, an application that calls posix_spawn_file_actions_adddup2() with an arbitrary integer for newfildes risks non-conforming behavior, and this function can only portably be used to overwrite file descriptor values that the application has obtained through explicit actions, or for the three file descriptors corresponding to the standard file streams. π«Ά
and to avoid a race condition of leaking an unintended file descriptor into a child process, an application should consider opening all file descriptors with the FD_CLOEXEC bit set, unless the file descriptor is intended to be inherited across exec. no cap, that's the move. β¨
π RATIONALE π
refer to the RATIONALE section in posix_spawn_file_actions_addclose(). go read that one bestie, I'm not repeating myself. π
β FUTURE DIRECTIONS β
None. β the future is empty, and honestly? that's a vibe. π¦
πΈ SEE ALSO πΈ
dup()posix_spawn()posix_spawn_file_actions_addclose()posix_spawn_file_actions_destroy()
the Base Definitions volume of POSIX.1β2017, <spawn.h> π
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version 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 . π«Ά
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . π
and that's the whole page bestie!! brought to you by IEEE/The Open Group, 2017, filed under POSIX_S...ADDDUP2(3POSIX) β stay posix-compliant and stay gorgeous π
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms