https://github.com/python/cpython/commit/a85a674b57b7f12e77ac4bef2398c09f36fec75a
commit: a85a674b57b7f12e77ac4bef2398c09f36fec75a
branch: main
author: Benjamin Peterson <[email protected]>
committer: benjaminp <[email protected]>
date: 2026-07-18T12:26:11-07:00
summary:

gh-153856: Add `os.RWF_NOSIGNAL` constant (#153858)

RWF_NOSIGNAL was added in Linux 6.18 to prevent pwritev2() from raising SIGPIPE 
when writing to disconnected pipes or sockets.

fixes gh-153856

files:
A Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153856.JEHepm.rst
M Doc/library/os.rst
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c

diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 5858d9733c57796..be7ea26356bebe3 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -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
index 000000000000000..f0af3de70848339
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-07-17-14-30-00.gh-issue-153856.JEHepm.rst
@@ -0,0 +1 @@
+Add :data:`os.RWF_NOSIGNAL` constant for Linux 6.18+.
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 1f7e414b2dfe48f..ac9b63dec9eb440 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -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 @@ os__emscripten_log(PyObject *module, PyObject *const 
*args, Py_ssize_t nargs, Py
 #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]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4c26ee52279abcd..02d25adddd62675 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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__)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to