[New-bugs-announce] [issue30654] signal module always overwrites SIGINT on interpreter shutdown

pkerling report at bugs.python.org
Tue Jun 13 09:06:04 EDT 2017


New submission from pkerling:

The signal module checks the SIGINT handler on startup. It only registers a new custom handler if the default OS handler is still installed, so that when embedding python in an application the SIGINT handler of that application is not overwritten. 

But on shutdown in finisignal, it *always* sets SIGINT to SIG_DFL. The reason is that it saves the old handler in old_siginthandler, but *only* if the signal handler is overwritten in init, which only happens when it was SIG_DFL in the first place! If there was already a handler in place in init (-> no overwriting), old_siginthandler will default to the initialization value, which is also SIG_DFL.

This means that when an application embeds Python and needs a custom SIGINT handler, it will stop to work as soon as it shuts down Python since it will always be reset to SIG_DFL.

----------
components: Interpreter Core
messages: 295915
nosy: pkerling
priority: normal
severity: normal
status: open
title: signal module always overwrites SIGINT on interpreter shutdown
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30654>
_______________________________________


More information about the New-bugs-announce mailing list