Howdy all,

I'm looking to replace some usages of ‘os.system’ with the more secure
‘subprocess.Popen’ methods.

The module documentation has a section on replacing ‘os.system’
<http://docs.python.org/library/subprocess#replacing-os-system>, which
says to use::

    process = subprocess.Popen("mycmd" + " myarg", shell=True)
    status = os.waitpid(process.pid, 0)

But a ‘Popen’ instance has its own ‘wait’ method, which waits for exit
<URL:http://docs.python.org/library/subprocess#subprocess.Popen.wait>.
Why would I use ‘os.waitpid’ instead of::

    process = subprocess.Popen("mycmd" + " myarg", shell=True)
    process.wait()
    status = process.returncode

-- 
 \       “The best is the enemy of the good.” —Voltaire, _Dictionnaire |
  `\                                                    Philosophique_ |
_o__)                                                                  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to