diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-09-02 14:29:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-02 14:29:12 (GMT) |
commit | f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf (patch) | |
tree | ead7d1e470a2cd6bc4c3a0e1d787d747c8fa7522 /Modules/signalmodule.c | |
parent | 51fece1bb8d7aa22f114172a256714fe24788e31 (diff) | |
download | cpython-f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf.zip cpython-f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf.tar.gz cpython-f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf.tar.bz2 |
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) {
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 7bc1b53..c49a3ea 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -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; } |