]> granicus.if.org Git - python/commitdiff
SF patch [#466877] SIGBREAK is missing from signal module.
authorTim Peters <tim.peters@gmail.com>
Mon, 1 Oct 2001 17:58:40 +0000 (17:58 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 1 Oct 2001 17:58:40 +0000 (17:58 +0000)
Patch from Steve Scott to add SIGBREAK support (unique to Windows).

Misc/ACKS
Misc/NEWS
Modules/signalmodule.c

index 753aa734a44510b5d5d55f22c1c161ea493d6368..19bcf2ce76ffb558e097490fa28cfd3918215711 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -362,6 +362,7 @@ Peter Schneider-Kamp
 Sam Schulenburg
 Dietmar Schwertberger
 Barry Scott
+Steven Scott
 Nick Seidenman
 Fred Sells
 Denis Severson
index b7ccc862ca2b37550f11e3f7758ba3ccf766ffa0..662bd69cdd0aa2220211f272b5b09d1a61e8c915 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,26 @@ Tests
 
 Windows
 
+- The signal module now supports SIGBREAK on Windows, thanks to Steven
+  Scott.  Note that SIGBREAK is unique to Windows.  The default SIGBREAK
+  action remains to call Win32 ExitProcess().  This can be changed via
+  signal.signal().  For example:
+
+  # Make Ctrl+Break raise KeyboardInterrupt, like Python's default Ctrl+C
+  # (SIGINT) behavior.
+  import signal
+  signal.signal(signal.SIGBREAK,
+                signal.default_int_handler)
+
+  try:
+      while 1:
+          pass
+  except KeyboardInterrupt:
+      # We get here on Ctrl+C or Ctrl+Break now; if we had not changed
+      # SIGBREAK, only on Ctrl+C (and Ctrl+Break would terminate the
+      # program without the possibility for any Python-level cleanup).
+      print "Clean exit"
+
 
 What's New in Python 2.2a4?
 Release date: 28-Sep-2001
index 340445fc59c3f6dfbe9163af35776b2902e954f6..850221ea326c733bc94037f8f2b2a13465a65319 100644 (file)
@@ -383,6 +383,11 @@ initsignal(void)
        PyDict_SetItemString(d, "SIGINT", x);
         Py_XDECREF(x);
 #endif
+#ifdef SIGBREAK
+       x = PyInt_FromLong(SIGBREAK);
+       PyDict_SetItemString(d, "SIGBREAK", x);
+        Py_XDECREF(x);
+#endif
 #ifdef SIGQUIT
        x = PyInt_FromLong(SIGQUIT);
        PyDict_SetItemString(d, "SIGQUIT", x);