]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-137490: Fix signal.sigwaitinfo() on NetBSD (GH-137523)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 15 Sep 2025 16:20:31 +0000 (19:20 +0300)
committerGitHub <noreply@github.com>
Mon, 15 Sep 2025 16:20:31 +0000 (19:20 +0300)
Handle ECANCELED in the same way as EINTR to work around the Posix
violation in the NetBSD's implementation.

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 02bfdab957fc5219896909e96e9c4119ef77b734..3c79ef1429087a76c57620936c3dca7fa3969491 100644 (file)
@@ -1183,7 +1183,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;