mdwsetup.py: Turn off Python's usual `SIGINT' handler.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 13 Apr 2020 11:29:22 +0000 (12:29 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 May 2020 11:30:13 +0000 (12:30 +0100)
Without this, a buggy native-code extension can loop forever, and Emacs
can't easily be persuaded to kill it.

mdwsetup.py

index 55120fb..876297e 100644 (file)
@@ -28,12 +28,22 @@ from __future__ import with_statement
 import sys as SYS
 import os as OS
 import re as RE
+import signal as SIG
 import subprocess as SUB
 
 import distutils.core as DC
 import distutils.log as DL
 
 ###--------------------------------------------------------------------------
+### Preliminaries.
+
+## Turn off Python's `SIGINT' handler.  If we get stuck in a native-code loop
+## then ^C will just set a flag that will be noticed by the main interpreter
+## loop if we ever get to it again.  And raising `SIGINT' is how Emacs `C-c
+## C-k' aborts a compilation, so this is really unsatisfactory.
+SIG.signal(SIG.SIGINT, SIG.SIG_DFL)
+
+###--------------------------------------------------------------------------
 ### Compatibility hacks.
 
 def with_metaclass(meta, *supers):