Always install default signal handler for SIGINT. #1413
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reason for this fix is that in my case I created a systemd unit file for CentOS7.
Issuing
systemctl stop digits
makes it sendSIGTERM
to the Python process, but there is no handler for this. Inpackaging/deb/templates/digits.service
I see there is a "hack" for Debian (make systemd use SIGINT instead of SIGTERM), but that doesn't seem to work on CentOS7. So what I did is create a bash script that traps SIGTERM from systemd and translates it into a SIGINT for Python.Anyway in this case, the way Python is launched (as a subshell) it won't register the default handler for SIGINT. This is a small fix that simply always registers the SIGINT handler.. More info: http://stackoverflow.com/questions/40775054/capturing-sigint-using-keyboardinterrupt-exception-works-in-terminal-not-in-scr/40785230#40785230
I have another suggestion, maybe it's a better idea to additionally listen for SIGTERM?
If that is preferred I can update this PR with that solution?