Skip to content

Commit

Permalink
Merged revisions 79181 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/python/trunk

........
  r79181 | georg.brandl | 2010-03-21 10:51:16 +0100 (So, 21 Mär 2010) | 1 line

  Update os.kill() emulation example for Windows to use ctypes.
........
  • Loading branch information
birkenfeld committed Mar 21, 2010
1 parent 718ce2c commit ff24c8e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Doc/faq/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,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?
Expand Down

0 comments on commit ff24c8e

Please sign in to comment.