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 /Doc | |
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 'Doc')
-rw-r--r-- | Doc/library/os.rst | 9 | ||||
-rw-r--r-- | Doc/library/signal.rst | 14 | ||||
-rw-r--r-- | Doc/library/subprocess.rst | 5 |
3 files changed, 25 insertions, 3 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index b4e39a4..11d9607 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1719,7 +1719,14 @@ written in Python, such as a mail server's external command delivery program. Send signal *sig* to the process *pid*. Constants for the specific signals available on the host platform are defined in the :mod:`signal` module. - Availability: Unix. + + Windows: The :data:`signal.CTRL_C_EVENT` and + :data:`signal.CTRL_BREAK_EVENT` signals are special signals which can + only be sent to console processes which share a common console window, + e.g., some subprocesses. Any other value for *sig* will cause the process + to be unconditionally killed by the TerminateProcess API, and the exit code + will be set to *sig*. The Windows version of :func:`kill` additionally takes + process handles to be killed. .. function:: killpg(pgid, sig) diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst index 84f08b3..300c717 100644 --- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -75,6 +75,20 @@ The variables defined in the :mod:`signal` module are: the system are defined by this module. +.. data:: CTRL_C_EVENT + + The signal corresponding to the CTRL+C keystroke event. + + Availability: Windows. + + +.. data:: CTRL_BREAK_EVENT + + The signal corresponding to the CTRL+BREAK keystroke event. + + Availability: Windows. + + .. data:: NSIG One more than the number of the highest signal number. diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index b557bcd..439a46d 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -320,8 +320,9 @@ Instances of the :class:`Popen` class have the following methods: .. note:: - On Windows only SIGTERM is supported so far. It's an alias for - :meth:`terminate`. + On Windows, SIGTERM is an alias for :meth:`terminate`. CTRL_C_EVENT and + CTRL_BREAK_EVENT can be sent to processes started with a `creationflags` + parameter which includes `CREATE_NEW_PROCESS_GROUP`. .. versionadded:: 2.6 |