Proper way to kill child processes

Jean Brouwers mrjean1 at comcast.net
Wed Jun 16 00:13:22 CEST 2004


It should be the other way around

 self.popen = popen2.Popen3(["/usr/local/bin/python", 
                        "-O", "myscript.py"])

Item [0] must be the path to the executable and items[1:] are the
arguments.  See the Popen3._run_cmd() method in Lib/popen2.py
partially copied here:

<pre>
    def _run_child(self, cmd):
        if isinstance(cmd, basestring):
            cmd = ['/bin/sh', '-c', cmd]
        .....
        try:
            os.execvp(cmd[0], cmd)
        finally:
            os._exit(1)
</pre>

/Jean Brouwers
 ProphICy Semiconductor, Inc.

In article <1774q1-63c.ln1 at valpo.de>, Mathias Waack <M.Waack at gmx.de>
wrote:

> Bob Swerdlow wrote:
> 
> > My application starts up a number of processes for various purposes
> > using:
> >     self.popen = popen2.Popen3("/usr/local/bin/python -O
> >     "myscript.py")
> 
> This works for me:
> 
>   self.popen = popen2.Popen3(["python", "/usr/local/bin/python", 
>                         "-O", "myscript.py"])
> 
> But I don't know if its a hack or a desired feature. 
> 
> Mathias



More information about the Python-list mailing list