Can Python kill a child process that keeps on running?

Steve Holden steve at
Tue May 2 04:10:17 CEST 2006

I. Myself wrote:
> Serge Orlov wrote:
>>I. Myself wrote:
>>>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.
>>On linux it's pretty easy to do, just setup alarm signal. On windows
>>it's not so trivial to the point you cannot do it using
>>distribution, you will need to poke in low level C API using win32
>>extensions or ctypes. AFAIK twisted package <>
>>has some code to help you. Also take a look at buildbot sources
>><> that uses twisted. Buildbot has the same
>>problem as you have, it needs to kill run away or non-responding
> That is bad news.   Thanks anyway; bad news is better than no news.
Note, however, taht ctypes is planned to be a part of the 2.5 
distribution, so while there may not be a platform-independent way to 
achieve your goals you will at leats be able to do so without external 

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd
Love me, love my blog
Recent Ramblings

More information about the Python-list mailing list