Skip to content

bpo-46016: fcntl module add FreeBSD's F_DUP2FD_CLOEXEC flag support. #29993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/library/fcntl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ descriptor.
``F_SETPIPE_SZ`` constants, which allow to check and modify a pipe's size
respectively.

.. versionchanged:: 3.11
On FreeBSD, the fcntl module exposes the ``F_DUP2FD`` and ``F_DUP2FD_CLOEXEC``
constants, which allow to duplicate a file descriptor, the latter setting
``FD_CLOEXEC`` flag in addition.

The module defines the following functions:


Expand Down
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ unicodedata
* The Unicode database has been updated to version 14.0.0. (:issue:`45190`).


fcntl
-----

* On FreeBSD, the `F_DUP2FD` and `F_DUP2FD_CLOEXEC` flags respectively
are supported, the former equals to ``dup2`` usage while the latter set
the ``FD_CLOEXEC`` flag in addition.


Optimizations
=============

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding `F_DUP2FD` and `F_DUP2FD_CLOEXEC` constants from FreeBSD into the fcntl module.
8 changes: 8 additions & 0 deletions Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ all_ins(PyObject* m)
if (PyModule_AddIntMacro(m, F_NOCACHE)) return -1;
#endif

/* FreeBSD specifics */
#ifdef F_DUP2FD
if (PyModule_AddIntMacro(m, F_DUP2FD)) return -1;
#endif
#ifdef F_DUP2FD_CLOEXEC
if (PyModule_AddIntMacro(m, F_DUP2FD_CLOEXEC)) return -1;
#endif

/* For F_{GET|SET}FL */
#ifdef FD_CLOEXEC
if (PyModule_AddIntMacro(m, FD_CLOEXEC)) return -1;
Expand Down