File bpo-41675-modernize-siginterrupt.patch of Package python3.34506

From 878403d20e358f85285f4cb17f30ba6449cac058 Mon Sep 17 00:00:00 2001
From: Pablo Galindo <pablogsal@gmail.com>
Date: Mon, 31 Aug 2020 14:53:33 +0100
Subject: [PATCH] Modernize siginterrupt calls

The implementation of `signal.siginterrupt` now uses `sigaction`
(if it is available in the system) instead of the deprecated
`siginterrupt`.

Fixes: gh#python/cpython#85841
From-PR: gh#python/cpython!22028
Patch: bpo-41675-modernize-siginterrupt.patch
---
 .../2020-08-31-14-53-17.bpo-41675.VSoqWU.rst       |  3 +++
 Modules/signalmodule.c                             | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-08-31-14-53-17.bpo-41675.VSoqWU.rst

diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-08-31-14-53-17.bpo-41675.VSoqWU.rst b/Misc/NEWS.d/next/Core and Builtins/2020-08-31-14-53-17.bpo-41675.VSoqWU.rst
new file mode 100644
index 00000000000..aa102f8fe43
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-08-31-14-53-17.bpo-41675.VSoqWU.rst	
@@ -0,0 +1,3 @@
+The implementation of :func:`signal.siginterrupt` now uses :c:func:`sigaction`
+(if it is available in the system) instead of the deprecated :c:func:`siginterrupt`.
+Patch by Pablo Galindo.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index d24f18ad3b9..64630655a87 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -532,7 +532,19 @@ signal_siginterrupt_impl(PyObject *module, int signalnum, int flag)
                         "signal number out of range");
         return NULL;
     }
-    if (siginterrupt(signalnum, flag)<0) {
+#ifdef HAVE_SIGACTION
+    struct sigaction act;
+    (void) sigaction(signalnum, NULL, &act);
+    if (flag) {
+        act.sa_flags &= ~SA_RESTART;
+    }
+    else {
+        act.sa_flags |= SA_RESTART;
+    }
+    if (sigaction(signalnum, &act, NULL) < 0) {
+#else
+    if (siginterrupt(signalnum, flag) < 0) {
+#endif
         PyErr_SetFromErrno(PyExc_OSError);
         return NULL;
     }
-- 
2.45.0
openSUSE Build Service is sponsored by