]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-137490: Fix signal.sigwaitinfo() on NetBSD (GH-137523) (GH-138936)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 15 Sep 2025 16:43:32 +0000 (18:43 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Sep 2025 16:43:32 +0000 (16:43 +0000)
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.
(cherry picked from commit 07d0b95b05dfaf5832f44c2fbc956761f9e29571)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Misc/NEWS.d/next/Library/2025-08-07-17-18-57.gh-issue-137490.s89ieZ.rst [new file with mode: 0644]
Modules/signalmodule.c

diff --git a/Misc/NEWS.d/next/Library/2025-08-07-17-18-57.gh-issue-137490.s89ieZ.rst b/Misc/NEWS.d/next/Library/2025-08-07-17-18-57.gh-issue-137490.s89ieZ.rst
new file mode 100644 (file)
index 0000000..bcb0938
--- /dev/null
@@ -0,0 +1,2 @@
+Handle :data:`~errno.ECANCELED` in the same way as :data:`~errno.EINTR` in
+:func:`signal.sigwaitinfo` on NetBSD.
index 3c7bea5d0c13d0e098b03ee03cb2ba0627179f9d..6f53dcda8246790a4c5fda22c35885c3c5539b34 100644 (file)
@@ -1178,7 +1178,13 @@ signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
         err = sigwaitinfo(&sigset, &si);
         Py_END_ALLOW_THREADS
     } while (err == -1
-             && errno == EINTR && !(async_err = PyErr_CheckSignals()));
+             && (errno == EINTR
+#if defined(__NetBSD__)
+                 /* NetBSD's implementation violates POSIX by setting
+                  * errno to ECANCELED instead of EINTR. */
+                 || errno == ECANCELED
+#endif
+            ) && !(async_err = PyErr_CheckSignals()));
     if (err == -1)
         return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;