Waiting for a subprocess to exit

Ben Finney ben+python at benfinney.id.au
Fri Aug 21 10:49:19 CEST 2009


Miles Kaufmann <milesck at umich.edu> writes:

> On Aug 20, 2009, at 10:13 PM, Ben Finney wrote:
> > Why would I use ‘os.waitpid’ instead of::
> >
> >    process = subprocess.Popen("mycmd" + " myarg", shell=True)
> >    process.wait()
> >    status = process.returncode
>
> Really, you can just use:
>
>   process = subprocess.Popen("mycmd" + " myarg", shell=True)
>   status = process.wait()

Ah thanks, that's even better.

> I'm not sure why the documentation suggests using os.waitpid.

Could someone who knows how to drive the Python BTS please report that
against the ‘subprocess’ documentation?

-- 
 \       “I am amazed, O Wall, that you have not collapsed and fallen, |
  `\            since you must bear the tedious stupidities of so many |
_o__)                  scrawlers.” —anonymous graffiti, Pompeii, 79 CE |
Ben Finney



More information about the Python-list mailing list