Run process with timeout
Donn Cave
donn at u.washington.edu
Mon Oct 17 18:05:35 EDT 2005
In article <1h4lkml.gx8kslqnnnflN%aleaxit at yahoo.com>,
aleaxit at yahoo.com (Alex Martelli) wrote:
> Micah Elliott <mde at micah.elliott.name> 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 u.washington.edu
More information about the Python-list
mailing list