diff options
author | Victor Stinner <vstinner@python.org> | 2020-11-17 15:22:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 15:22:23 (GMT) |
commit | 296a796951032f678d063008f588ccc6958d0df1 (patch) | |
tree | 91fa9ac02ef9786aeb741d13d07a0cd027d34d02 /Modules | |
parent | 975022b77b0024ea1548f19d5f91aba5ba1eed59 (diff) | |
download | cpython-296a796951032f678d063008f588ccc6958d0df1.zip cpython-296a796951032f678d063008f588ccc6958d0df1.tar.gz cpython-296a796951032f678d063008f588ccc6958d0df1.tar.bz2 |
bpo-41713: Remove PyOS_InitInterrupts() function (GH-23342)
Remove the undocumented PyOS_InitInterrupts() C function.
* Rename PyOS_InitInterrupts() to _PySignal_Init(). It now installs
other signal handlers, not only SIGINT.
* Rename PyOS_FiniInterrupts() to _PySignal_Fini()
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/signalmodule.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 0ab3a71..c0b2117 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1674,8 +1674,8 @@ PyInit__signal(void) } -static void -finisignal(void) +void +_PySignal_Fini(void) { int i; PyObject *func; @@ -1792,19 +1792,32 @@ PyErr_SetInterrupt(void) } } -void -PyOS_InitInterrupts(void) +int +_PySignal_Init(int install_signal_handlers) { - PyObject *m = PyImport_ImportModule("_signal"); - if (m) { - Py_DECREF(m); + if (!install_signal_handlers) { + // Nothing to do + return 0; } -} -void -PyOS_FiniInterrupts(void) -{ - finisignal(); +#ifdef SIGPIPE + PyOS_setsig(SIGPIPE, SIG_IGN); +#endif +#ifdef SIGXFZ + PyOS_setsig(SIGXFZ, SIG_IGN); +#endif +#ifdef SIGXFSZ + PyOS_setsig(SIGXFSZ, SIG_IGN); +#endif + + // Import _signal to install the Python SIGINT handler + PyObject *module = PyImport_ImportModule("_signal"); + if (!module) { + return -1; + } + Py_DECREF(module); + + return 0; } |