Can Python kill a child process that keeps on running?

Roger Upole rupole at hotmail.com
Fri May 5 22:33:53 EDT 2006


Using Pywin32 (obviously not cross platform):

import win32api,win32con
h=win32api.OpenProcess(win32con.PROCESS_TERMINATE,False, <pid>)
win32api.TerminateProcess(h, <exit code>)

        Roger

"I. Myself" <No.Spam at Spam.none> wrote in message news:g0x5g.104639$7a.102977 at pd7tw1no...
> Suppose we spawn a child process with Popen.  I'm thinking of an executable file, like a compiled C program.
> Suppose it is supposed to run for one minute, but it just keeps going and going.  Does Python have any way to kill it?
>
> This is not hypothetical; I'm doing it now, and it's working pretty well, but I would like to be able to handle this run-on 
> condition.  I'm using Windows 2000, but I want my program to be portable to linux.
>
> Thanks
>
> Mitchell Timin
>
> -- 
> I'm proud of http://ANNEvolve.sourceforge.net.  If you want to write software,
> or articles, or do testing or research for ANNEvolve, let me know.
>
> Humans may know that my email address is: (but remove the 3 digit number)
> zenguy at shaw666 dot ca
>
>
> 



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list