Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f9c5e3f

Browse filesBrowse 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
Copy full SHA for f9c5e3f

File tree

2 files changed

+16
-1
lines changed
Filter options

2 files changed

+16
-1
lines changed
+3Lines changed: 3 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: Modules/signalmodule.c
+13-1Lines changed: 13 additions & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.