]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46016: fcntl module add FreeBSD's F_DUP2FD_CLOEXEC flag support (GH-29993)
authorDavid CARLIER <devnexen@gmail.com>
Wed, 8 Dec 2021 22:28:51 +0000 (22:28 +0000)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 22:28:51 +0000 (23:28 +0100)
Doc/library/fcntl.rst
Doc/whatsnew/3.11.rst
Misc/NEWS.d/next/Library/2021-12-08-19-15-03.bpo-46016.s9PuyF.rst [new file with mode: 0644]
Modules/fcntlmodule.c

index 9d8021150c42f51a02d3f20ca11580544b5ff172..846c8d7ba96dabc39c18cd5de0e96be40282bb2e 100644 (file)
@@ -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:
 
 
index a570864743d47fb912ca38f6bfcc142af8556290..264a801da7899d8682bd200acaad11443b6825ea 100644 (file)
@@ -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
 =============
 
diff --git a/Misc/NEWS.d/next/Library/2021-12-08-19-15-03.bpo-46016.s9PuyF.rst b/Misc/NEWS.d/next/Library/2021-12-08-19-15-03.bpo-46016.s9PuyF.rst
new file mode 100644 (file)
index 0000000..7308c54
--- /dev/null
@@ -0,0 +1 @@
+Adding `F_DUP2FD` and `F_DUP2FD_CLOEXEC` constants from FreeBSD into the fcntl module.
index cdf0f9bf3790e2b06cabbd3839de17c3caef5bff..ea9b2bc14a9f24e7265ee837afe99e5edaea8702 100644 (file)
@@ -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;