Kaydet (Commit) f23f0a2c authored tarafından Georg Brandl's avatar Georg Brandl

Update os.kill() emulation example for Windows to use ctypes.

üst a39f2afe
...@@ -441,13 +441,15 @@ present, and ``getch()`` which gets one character without echoing it. ...@@ -441,13 +441,15 @@ present, and ``getch()`` which gets one character without echoing it.
How do I emulate os.kill() in Windows? How do I emulate os.kill() in Windows?
-------------------------------------- --------------------------------------
Use win32api:: To terminate a process, you can use ctypes::
import ctypes
def kill(pid): def kill(pid):
"""kill function for Win32""" """kill function for Win32"""
import win32api kernel32 = ctypes.windll.kernel32
handle = win32api.OpenProcess(1, 0, pid) handle = kernel32.OpenProcess(1, 0, pid)
return (0 != win32api.TerminateProcess(handle, 0)) return (0 != kernel32.TerminateProcess(handle, 0))
Why does os.path.isdir() fail on NT shared directories? Why does os.path.isdir() fail on NT shared directories?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment