Skip to content

Commit 07d0b95

Browse files
gh-137490: Fix signal.sigwaitinfo() on NetBSD (GH-137523)
Handle ECANCELED in the same way as EINTR to work around the Posix violation in the NetBSD's implementation.
1 parent fa12c6b commit 07d0b95

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
@@ -1183,7 +1183,13 @@ signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
11831183
err = sigwaitinfo(&sigset, &si);
11841184
Py_END_ALLOW_THREADS
11851185
} while (err == -1
1186-
&& errno == EINTR && !(async_err = PyErr_CheckSignals()));
1186+
&& (errno == EINTR
1187+
#if defined(__NetBSD__)
1188+
/* NetBSD's implementation violates POSIX by setting
1189+
* errno to ECANCELED instead of EINTR. */
1190+
|| errno == ECANCELED
1191+
#endif
1192+
) && !(async_err = PyErr_CheckSignals()));
11871193
if (err == -1)
11881194
return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
11891195

0 commit comments

Comments
 (0)