Skip to content

Commit c5377a7

Browse files
serhiy-storchakamiss-islington
authored andcommitted
pythongh-137490: Fix signal.sigwaitinfo() on NetBSD (pythonGH-137523)
Handle ECANCELED in the same way as EINTR to work around the Posix violation in the NetBSD's implementation. (cherry picked from commit 07d0b95) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent dc4d016 commit c5377a7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Handle :data:`~errno.ECANCELED` in the same way as :data:`~errno.EINTR` in
2+
:func:`signal.sigwaitinfo` on NetBSD.

Modules/signalmodule.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,13 @@ signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
11801180
err = sigwaitinfo(&sigset, &si);
11811181
Py_END_ALLOW_THREADS
11821182
} while (err == -1
1183-
&& errno == EINTR && !(async_err = PyErr_CheckSignals()));
1183+
&& (errno == EINTR
1184+
#if defined(__NetBSD__)
1185+
/* NetBSD's implementation violates POSIX by setting
1186+
* errno to ECANCELED instead of EINTR. */
1187+
|| errno == ECANCELED
1188+
#endif
1189+
) && !(async_err = PyErr_CheckSignals()));
11841190
if (err == -1)
11851191
return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
11861192

0 commit comments

Comments
 (0)