mirror of
https://github.com/python/cpython.git
synced 2026-02-13 19:04:37 +00:00
Update os.kill() emulation example for Windows to use ctypes.
This commit is contained in:
parent
a39f2afe9b
commit
f23f0a2c7c
1 changed files with 6 additions and 4 deletions
|
|
@ -441,13 +441,15 @@ present, and ``getch()`` which gets one character without echoing it.
|
|||
How do I emulate os.kill() in Windows?
|
||||
--------------------------------------
|
||||
|
||||
Use win32api::
|
||||
To terminate a process, you can use ctypes::
|
||||
|
||||
import ctypes
|
||||
|
||||
def kill(pid):
|
||||
"""kill function for Win32"""
|
||||
import win32api
|
||||
handle = win32api.OpenProcess(1, 0, pid)
|
||||
return (0 != win32api.TerminateProcess(handle, 0))
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
handle = kernel32.OpenProcess(1, 0, pid)
|
||||
return (0 != kernel32.TerminateProcess(handle, 0))
|
||||
|
||||
|
||||
Why does os.path.isdir() fail on NT shared directories?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue