diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-04-02 23:26:06 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-04-02 23:26:06 (GMT) |
commit | e5aa886b4449c9b2db93591c58511ea3620c9b67 (patch) | |
tree | aa333dc52ff6f99c1443b117b26c50a6afbdb7a9 /Modules/signalmodule.c | |
parent | a04c7a0f169caf09b181df05836e4cf175f37dbe (diff) | |
download | cpython-e5aa886b4449c9b2db93591c58511ea3620c9b67.zip cpython-e5aa886b4449c9b2db93591c58511ea3620c9b67.tar.gz cpython-e5aa886b4449c9b2db93591c58511ea3620c9b67.tar.bz2 |
Implement #1220212. Add os.kill support for Windows.
os.kill takes one of two newly added signals, CTRL_C_EVENT and
CTRL_BREAK_EVENT, or any integer value. The events are a special case
which work with subprocess console applications which implement a
special console control handler. Any other value but those two will
cause os.kill to use TerminateProcess, outright killing the process.
This change adds win_console_handler.py, which is a script to implement
SetConsoleCtrlHandler and applicable handler function, using ctypes.
subprocess also gets another attribute which is a necessary flag to
creationflags in Popen in order to send the CTRL events.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index cecb2be..bb7e4b0 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -7,6 +7,7 @@ #include "intrcheck.h" #ifdef MS_WINDOWS +#include <Windows.h> #ifdef HAVE_PROCESS_H #include <process.h> #endif @@ -793,6 +794,18 @@ initsignal(void) PyDict_SetItemString(d, "ItimerError", ItimerError); #endif +#ifdef CTRL_C_EVENT + x = PyInt_FromLong(CTRL_C_EVENT); + PyDict_SetItemString(d, "CTRL_C_EVENT", x); + Py_DECREF(x); +#endif + +#ifdef CTRL_BREAK_EVENT + x = PyInt_FromLong(CTRL_BREAK_EVENT); + PyDict_SetItemString(d, "CTRL_BREAK_EVENT", x); + Py_DECREF(x); +#endif + if (!PyErr_Occurred()) return; |