chiark / gitweb /
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 55120fb116438b40cebbad25b55f8f073be70345..876297ed4e74b6cc7bb16409a4f7fe725d2c1796 100644 (file)
@@ -28,11 +28,21 @@ 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.