mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
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.
This commit is contained in:
parent
a04c7a0f16
commit
e5aa886b44
10 changed files with 197 additions and 6 deletions
|
|
@ -990,6 +990,10 @@ class Popen(object):
|
|||
"""
|
||||
if sig == signal.SIGTERM:
|
||||
self.terminate()
|
||||
elif sig == signal.CTRL_C_EVENT:
|
||||
os.kill(self.pid, signal.CTRL_C_EVENT)
|
||||
elif sig == signal.CTRL_BREAK_EVENT:
|
||||
os.kill(self.pid, signal.CTRL_BREAK_EVENT)
|
||||
else:
|
||||
raise ValueError("Only SIGTERM is supported on Windows")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue