]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-153856: Add `os.RWF_NOSIGNAL` constant (#153858)
authorBenjamin Peterson <benjamin@python.org>
Sat, 18 Jul 2026 19:26:11 +0000 (12:26 -0700)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2026 19:26:11 +0000 (12:26 -0700)
RWF_NOSIGNAL was added in Linux 6.18 to prevent pwritev2() from raising SIGPIPE when writing to disconnected pipes or sockets.

fixes gh-153856

Doc/library/os.rst
Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153856.JEHepm.rst [new file with mode: 0644]
Modules/clinic/posixmodule.c.h
Modules/posixmodule.c

index 5858d9733c57796d95e57d3a0a06ca2777a1519d..be7ea26356bebe34f3b0ebb4d29a3595fa495fc0 100644 (file)
@@ -1642,6 +1642,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
    - :data:`RWF_APPEND`
    - :data:`RWF_DONTCACHE`
    - :data:`RWF_ATOMIC`
+   - :data:`RWF_NOSIGNAL`
 
    Return the total number of bytes actually written.
 
@@ -1691,6 +1692,16 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
    .. versionadded:: 3.10
 
 
+.. data:: RWF_NOSIGNAL
+
+   Prevent pipe and socket writes from raising :const:`~signal.SIGPIPE`.
+   This flag is meaningful only for :func:`os.pwritev`.
+
+   .. availability:: Linux >= 6.18.
+
+   .. versionadded:: 3.16
+
+
 .. function:: read(fd, n, /)
 
    Read at most *n* bytes from file descriptor *fd*.
diff --git a/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153856.JEHepm.rst b/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153856.JEHepm.rst
new file mode 100644 (file)
index 0000000..f0af3de
--- /dev/null
@@ -0,0 +1 @@
+Add :data:`os.RWF_NOSIGNAL` constant for Linux 6.18+.
index 1f7e414b2dfe48f1844a64c75c6ffa3ef2fbf417..ac9b63dec9eb440217003ff03a6ac9c40b3ae982 100644 (file)
@@ -8801,6 +8801,7 @@ PyDoc_STRVAR(os_pwritev__doc__,
 "- RWF_APPEND\n"
 "- RWF_DONTCACHE\n"
 "- RWF_ATOMIC\n"
+"- RWF_NOSIGNAL\n"
 "\n"
 "Using non-zero flags requires Linux 4.7 or newer.");
 
@@ -13733,4 +13734,4 @@ exit:
 #ifndef OS__EMSCRIPTEN_LOG_METHODDEF
     #define OS__EMSCRIPTEN_LOG_METHODDEF
 #endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */
-/*[clinic end generated code: output=d81494ceb6ce44ed input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d641f02a97057666 input=a9049054013a1b77]*/
index 4c26ee52279abcd709fa3e0fb071ec80e9093682..02d25adddd6267578f4b6718dec64bd4bbe6cfc5 100644 (file)
@@ -12941,6 +12941,7 @@ following flags:
 - RWF_APPEND
 - RWF_DONTCACHE
 - RWF_ATOMIC
+- RWF_NOSIGNAL
 
 Using non-zero flags requires Linux 4.7 or newer.
 [clinic start generated code]*/
@@ -12948,7 +12949,7 @@ Using non-zero flags requires Linux 4.7 or newer.
 static Py_ssize_t
 os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
                 int flags)
-/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=b2e352a22f030e9a]*/
+/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=c202f24f01fa66c9]*/
 {
     Py_ssize_t cnt;
     Py_ssize_t result;
@@ -18246,6 +18247,9 @@ all_ins(PyObject *m)
 #ifdef RWF_APPEND
     if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
 #endif
+#ifdef RWF_NOSIGNAL
+    if (PyModule_AddIntConstant(m, "RWF_NOSIGNAL", RWF_NOSIGNAL)) return -1;
+#endif
 
 /* constants for splice */
 #if defined(HAVE_SPLICE) && defined(__linux__)