Skip to content

Commit d8b3a83

Browse files
[3.13] pythongh-137490: Fix signal.sigwaitinfo() on NetBSD (pythonGH-137523) (pythonGH-138936)
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 7452e95 commit d8b3a83

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
@@ -1178,7 +1178,13 @@ signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
11781178
err = sigwaitinfo(&sigset, &si);
11791179
Py_END_ALLOW_THREADS
11801180
} while (err == -1
1181-
&& errno == EINTR && !(async_err = PyErr_CheckSignals()));
1181+
&& (errno == EINTR
1182+
#if defined(__NetBSD__)
1183+
/* NetBSD's implementation violates POSIX by setting
1184+
* errno to ECANCELED instead of EINTR. */
1185+
|| errno == ECANCELED
1186+
#endif
1187+
) && !(async_err = PyErr_CheckSignals()));
11821188
if (err == -1)
11831189
return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
11841190

0 commit comments

Comments
 (0)