Skip to content

Commit f9c5e3f

Browse files
authored
bpo-41675: Modernize siginterrupt calls (GH-22028)
siginterrupt is deprecated: ./Modules/signalmodule.c:667:5: warning: ‘siginterrupt’ is deprecated: Use sigaction with SA_RESTART instead [-Wdeprecated-declarations] 667 | if (siginterrupt(signalnum, flag)<0) {
1 parent 51fece1 commit f9c5e3f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The implementation of :func:`signal.siginterrupt` now uses :c:func:`sigaction`
2+
(if it is available in the system) instead of the deprecated :c:func:`siginterrupt`.
3+
Patch by Pablo Galindo.

Modules/signalmodule.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,19 @@ signal_siginterrupt_impl(PyObject *module, int signalnum, int flag)
664664
"signal number out of range");
665665
return NULL;
666666
}
667-
if (siginterrupt(signalnum, flag)<0) {
667+
#ifdef HAVE_SIGACTION
668+
struct sigaction act;
669+
(void) sigaction(signalnum, NULL, &act);
670+
if (flag) {
671+
act.sa_flags &= ~SA_RESTART;
672+
}
673+
else {
674+
act.sa_flags |= SA_RESTART;
675+
}
676+
if (sigaction(signalnum, &act, NULL) < 0) {
677+
#else
678+
if (siginterrupt(signalnum, flag) < 0) {
679+
#endif
668680
PyErr_SetFromErrno(PyExc_OSError);
669681
return NULL;
670682
}

0 commit comments

Comments
 (0)