mirror of
https://github.com/python/cpython.git
synced 2025-12-08 02:08:20 +00:00
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) {
This commit is contained in:
parent
51fece1bb8
commit
f9c5e3f5f6
2 changed files with 16 additions and 1 deletions
|
|
@ -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.
|
||||||
|
|
@ -664,7 +664,19 @@ signal_siginterrupt_impl(PyObject *module, int signalnum, int flag)
|
||||||
"signal number out of range");
|
"signal number out of range");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#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) {
|
if (siginterrupt(signalnum, flag) < 0) {
|
||||||
|
#endif
|
||||||
PyErr_SetFromErrno(PyExc_OSError);
|
PyErr_SetFromErrno(PyExc_OSError);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue