Skip to content

Commit 1d5198f

Browse files
miss-islingtonpkerling
authored andcommitted
bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal (GH-7146) (GH-7307)
(cherry picked from commit e905c84) Co-authored-by: pkerling <[email protected]>
1 parent b9afe64 commit 1d5198f

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

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

12941287
#ifdef SIGHUP
@@ -1494,14 +1487,11 @@ finisignal(void)
14941487
int i;
14951488
PyObject *func;
14961489

1497-
PyOS_setsig(SIGINT, old_siginthandler);
1498-
old_siginthandler = SIG_DFL;
1499-
15001490
for (i = 1; i < NSIG; i++) {
15011491
func = Handlers[i].func;
15021492
_Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
15031493
Handlers[i].func = NULL;
1504-
if (i != SIGINT && func != NULL && func != Py_None &&
1494+
if (func != NULL && func != Py_None &&
15051495
func != DefaultHandler && func != IgnoreHandler)
15061496
PyOS_setsig(i, SIG_DFL);
15071497
Py_XDECREF(func);

0 commit comments

Comments
 (0)