Skip to content

Commit a85a674

Browse files
authored
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
1 parent a0c8329 commit a85a674

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

Doc/library/os.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16421642
- :data:`RWF_APPEND`
16431643
- :data:`RWF_DONTCACHE`
16441644
- :data:`RWF_ATOMIC`
1645+
- :data:`RWF_NOSIGNAL`
16451646

16461647
Return the total number of bytes actually written.
16471648

@@ -1691,6 +1692,16 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16911692
.. versionadded:: 3.10
16921693

16931694

1695+
.. data:: RWF_NOSIGNAL
1696+
1697+
Prevent pipe and socket writes from raising :const:`~signal.SIGPIPE`.
1698+
This flag is meaningful only for :func:`os.pwritev`.
1699+
1700+
.. availability:: Linux >= 6.18.
1701+
1702+
.. versionadded:: 3.16
1703+
1704+
16941705
.. function:: read(fd, n, /)
16951706

16961707
Read at most *n* bytes from file descriptor *fd*.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :data:`os.RWF_NOSIGNAL` constant for Linux 6.18+.

Modules/clinic/posixmodule.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12941,14 +12941,15 @@ following flags:
1294112941
- RWF_APPEND
1294212942
- RWF_DONTCACHE
1294312943
- RWF_ATOMIC
12944+
- RWF_NOSIGNAL
1294412945

1294512946
Using non-zero flags requires Linux 4.7 or newer.
1294612947
[clinic start generated code]*/
1294712948

1294812949
static Py_ssize_t
1294912950
os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
1295012951
int flags)
12951-
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=b2e352a22f030e9a]*/
12952+
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=c202f24f01fa66c9]*/
1295212953
{
1295312954
Py_ssize_t cnt;
1295412955
Py_ssize_t result;
@@ -18246,6 +18247,9 @@ all_ins(PyObject *m)
1824618247
#ifdef RWF_APPEND
1824718248
if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
1824818249
#endif
18250+
#ifdef RWF_NOSIGNAL
18251+
if (PyModule_AddIntConstant(m, "RWF_NOSIGNAL", RWF_NOSIGNAL)) return -1;
18252+
#endif
1824918253

1825018254
/* constants for splice */
1825118255
#if defined(HAVE_SPLICE) && defined(__linux__)

0 commit comments

Comments
 (0)