On Mon, 07 Dec 2009 11:04:06 +0100, Jean-Michel Pichavant wrote:

> When using shell=True, your process is started in a shell, meaning the 
> PID of your subprocess is not self.luca.pid, self.luca.pid is the PID of 
> the shell.

This isn't true for a simple command on Unix (meaning a program name plus
arguments, and redirections, rather than e.g. a pipeline or a command
using subshells, flow-control constructs, etc).

For a simple command, "/bin/sh -c 'prog arg arg ...'" will exec() the
program *without* fork()ing, so the program will "take over" the shell's
process and PID.

You can verify this by running e.g.:

        import subprocess
        p = subprocess.Popen('sleep 10', shell=True)
        print p.pid
        subprocess.call('ps')
        p.wait()


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to