Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ce3cf7

Browse files
committed
SF patch [#466877] SIGBREAK is missing from signal module.
Patch from Steve Scott to add SIGBREAK support (unique to Windows).
1 parent fbacaf7 commit 1ce3cf7

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ Peter Schneider-Kamp
362362
Sam Schulenburg
363363
Dietmar Schwertberger
364364
Barry Scott
365+
Steven Scott
365366
Nick Seidenman
366367
Fred Sells
367368
Denis Severson

Misc/NEWS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ Tests
3131

3232
Windows
3333

34+
- The signal module now supports SIGBREAK on Windows, thanks to Steven
35+
Scott. Note that SIGBREAK is unique to Windows. The default SIGBREAK
36+
action remains to call Win32 ExitProcess(). This can be changed via
37+
signal.signal(). For example:
38+
39+
# Make Ctrl+Break raise KeyboardInterrupt, like Python's default Ctrl+C
40+
# (SIGINT) behavior.
41+
import signal
42+
signal.signal(signal.SIGBREAK,
43+
signal.default_int_handler)
44+
45+
try:
46+
while 1:
47+
pass
48+
except KeyboardInterrupt:
49+
# We get here on Ctrl+C or Ctrl+Break now; if we had not changed
50+
# SIGBREAK, only on Ctrl+C (and Ctrl+Break would terminate the
51+
# program without the possibility for any Python-level cleanup).
52+
print "Clean exit"
53+
3454

3555
What's New in Python 2.2a4?
3656
Release date: 28-Sep-2001

Modules/signalmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ initsignal(void)
383383
PyDict_SetItemString(d, "SIGINT", x);
384384
Py_XDECREF(x);
385385
#endif
386+
#ifdef SIGBREAK
387+
x = PyInt_FromLong(SIGBREAK);
388+
PyDict_SetItemString(d, "SIGBREAK", x);
389+
Py_XDECREF(x);
390+
#endif
386391
#ifdef SIGQUIT
387392
x = PyInt_FromLong(SIGQUIT);
388393
PyDict_SetItemString(d, "SIGQUIT", x);

0 commit comments

Comments
 (0)