kill a process in XP

Cameron Laird claird at lairds.us
Wed Feb 23 20:08:03 EST 2005


In article <mailman.2971.1109178189.22381.python-list at python.org>,
Dave Brueck  <dave at pythonapocrypha.com> wrote:
>Tor Erik Sønvisen wrote:
>>>From my Python-program I spawn a new process. When using P_NOWAIT spawnl 
>> returns the pid but in windows it returns a process handle.
>> Later I want to kill this process. How can I do this when I only have the 
>> process handle?
>
>Try ctypes - if it's really a Windows handle, then this should work:
>
>from ctypes import *
>windll.kernel32.TerminateProcess(h, 0) # or whatever return code you want
>
>-Dave

I sometimes am so irritated with attendant portability issues
that I open a channel between parent and child, which I use to
send an exit-now message.



More information about the Python-list mailing list