Skip to content

Commit 623b439

Browse files
miss-islingtonpkerling
authored andcommitted
bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal (GH-7146) (GH-7306)
(cherry picked from commit e905c84) Co-authored-by: pkerling <pkerling@casix.org>
1 parent 3dd802d commit 623b439

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

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
@@ -118,13 +118,6 @@ static PyObject *DefaultHandler;
118118
static PyObject *IgnoreHandler;
119119
static PyObject *IntHandler;
120120

121-
/* On Solaris 8, gcc will produce a warning that the function
122-
declaration is not a prototype. This is caused by the definition of
123-
SIG_DFL as (void (*)())0; the correct declaration would have been
124-
(void (*)(int))0. */
125-
126-
static PyOS_sighandler_t old_siginthandler = SIG_DFL;
127-
128121
#ifdef MS_WINDOWS
129122
static HANDLE sigint_event = NULL;
130123
#endif
@@ -1291,7 +1284,7 @@ PyInit__signal(void)
12911284
/* Install default int handler */
12921285
Py_INCREF(IntHandler);
12931286
Py_SETREF(Handlers[SIGINT].func, IntHandler);
1294-
old_siginthandler = PyOS_setsig(SIGINT, signal_handler);
1287+
PyOS_setsig(SIGINT, signal_handler);
12951288
}
12961289

12971290
#ifdef SIGHUP
@@ -1497,14 +1490,11 @@ finisignal(void)
14971490
int i;
14981491
PyObject *func;
14991492

1500-
PyOS_setsig(SIGINT, old_siginthandler);
1501-
old_siginthandler = SIG_DFL;
1502-
15031493
for (i = 1; i < NSIG; i++) {
15041494
func = Handlers[i].func;
15051495
_Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
15061496
Handlers[i].func = NULL;
1507-
if (i != SIGINT && func != NULL && func != Py_None &&
1497+
if (func != NULL && func != Py_None &&
15081498
func != DefaultHandler && func != IgnoreHandler)
15091499
PyOS_setsig(i, SIG_DFL);
15101500
Py_XDECREF(func);

0 commit comments

Comments
 (0)