[2.7] bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal… · python/cpython@ded666f (original) (raw)

File tree

2 files changed

lines changed

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 +Fixed reset of the SIGINT handler to SIG_DFL on interpreter shutdown even
2 +when there was a custom handler set previously. Patch by Philipp Kerling.
Original file line number Diff line number Diff line change
@@ -95,13 +95,6 @@ static PyObject *DefaultHandler;
95 95 static PyObject *IgnoreHandler;
96 96 static PyObject *IntHandler;
97 97
98 -/* On Solaris 8, gcc will produce a warning that the function
99 - declaration is not a prototype. This is caused by the definition of
100 - SIG_DFL as (void (*)())0; the correct declaration would have been
101 - (void (*)(int))0. */
102 -
103 -static PyOS_sighandler_t old_siginthandler = SIG_DFL;
104 -
105 98 #ifdef HAVE_GETITIMER
106 99 static PyObject *ItimerError;
107 100
@@ -629,7 +622,7 @@ initsignal(void)
629 622 /* Install default int handler */
630 623 Py_INCREF(IntHandler);
631 624 Py_SETREF(Handlers[SIGINT].func, IntHandler);
632 -old_siginthandler = PyOS_setsig(SIGINT, signal_handler);
625 +PyOS_setsig(SIGINT, signal_handler);
633 626 }
634 627
635 628 #ifdef SIGHUP
@@ -872,14 +865,11 @@ finisignal(void)
872 865 int i;
873 866 PyObject *func;
874 867
875 -PyOS_setsig(SIGINT, old_siginthandler);
876 -old_siginthandler = SIG_DFL;
877 -
878 868 for (i = 1; i < NSIG; i++) {
879 869 func = Handlers[i].func;
880 870 Handlers[i].tripped = 0;
881 871 Handlers[i].func = NULL;
882 -if (i != SIGINT && func != NULL && func != Py_None &&
872 +if (func != NULL && func != Py_None &&
883 873 func != DefaultHandler && func != IgnoreHandler)
884 874 PyOS_setsig(i, SIG_DFL);
885 875 Py_XDECREF(func);