Skip to content

Commit ded666f

Browse files
authored
[2.7] bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal (GH-7146) (GH-7347)
(cherry picked from commit e905c84)
1 parent 9b5c948 commit ded666f

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

Modules/signalmodule.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ static PyObject *DefaultHandler;
9595
static PyObject *IgnoreHandler;
9696
static PyObject *IntHandler;
9797

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-
10598
#ifdef HAVE_GETITIMER
10699
static PyObject *ItimerError;
107100

@@ -629,7 +622,7 @@ initsignal(void)
629622
/* Install default int handler */
630623
Py_INCREF(IntHandler);
631624
Py_SETREF(Handlers[SIGINT].func, IntHandler);
632-
old_siginthandler = PyOS_setsig(SIGINT, signal_handler);
625+
PyOS_setsig(SIGINT, signal_handler);
633626
}
634627

635628
#ifdef SIGHUP
@@ -872,14 +865,11 @@ finisignal(void)
872865
int i;
873866
PyObject *func;
874867

875-
PyOS_setsig(SIGINT, old_siginthandler);
876-
old_siginthandler = SIG_DFL;
877-
878868
for (i = 1; i < NSIG; i++) {
879869
func = Handlers[i].func;
880870
Handlers[i].tripped = 0;
881871
Handlers[i].func = NULL;
882-
if (i != SIGINT && func != NULL && func != Py_None &&
872+
if (func != NULL && func != Py_None &&
883873
func != DefaultHandler && func != IgnoreHandler)
884874
PyOS_setsig(i, SIG_DFL);
885875
Py_XDECREF(func);

0 commit comments

Comments
 (0)