Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41675: Modernize siginterrupt calls #22028

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 13 additions & 1 deletion Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,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;
}
Expand Down