Run process with timeout

Donn Cave donn at
Tue Oct 18 00:05:35 CEST 2005

In article <1h4lkml.gx8kslqnnnflN%aleaxit at>,
 aleaxit at (Alex Martelli) wrote:
> Micah Elliott <mde at> wrote:

[... re problem killing children of shell script ...]

> > Is there any way to enable Python's subprocess module to do (implicit?)
> > group setup to ease killing of all children?  If not, is it a reasonable
> > RFE?
> Not as far as I know.  It might be a reasonable request in suitable
> dialects of Unix-like OSes, though.  A setpgrp call (in the callback
> which you can request Popen to perform, after it forks and before it
> execs) might suffice... except that you can't rely on children process
> not to setpgrp's themselves, can you?!

I bet that wouldn't be a problem, though.  subprocess.Popen
constructor takes a preexec_fn parameter that looks like it
might be a suitable place to try this.  (Interesting that
it's a function parameter, not a method to be overridden by
a subclass.)

   Donn Cave, donn at

More information about the Python-list mailing list