summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-03-21 09:51:16 (GMT)
committerGeorg Brandl <georg@python.org>2010-03-21 09:51:16 (GMT)
commitf23f0a2c7ce25890352f7a5a4ec2b5bfd63e4b44 (patch)
tree1361f15aa30ffb25675a30c411303a5c98610467 /Doc
parenta39f2afe9be7511bdb0d064dc5b14cf1ae4aa401 (diff)
downloadcpython-f23f0a2c7ce25890352f7a5a4ec2b5bfd63e4b44.zip
cpython-f23f0a2c7ce25890352f7a5a4ec2b5bfd63e4b44.tar.gz
cpython-f23f0a2c7ce25890352f7a5a4ec2b5bfd63e4b44.tar.bz2
Update os.kill() emulation example for Windows to use ctypes.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/faq/windows.rst10
1 files changed, 6 insertions, 4 deletions
diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst
index 2d701c8..353c400 100644
--- a/Doc/faq/windows.rst
+++ b/Doc/faq/windows.rst
@@ -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?