17.4 popen2 -- Subprocesses with accessible I/O streamsThis module allows you to spawn processes and connect to their input/output/error pipes and obtain their return codes under Unix and Windows. The subprocess module provides more powerful facilities for spawning new processes and retrieving their results. Using the subprocess module is preferable to using the popen2 module.
The primary interface offered by this module is a trio of factory
functions. For each of these, if bufsize is specified,
it specifies the buffer size for the I/O pipes. mode, if
provided, should be the string On Unix, cmd may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If cmd is a string it will be passed to the shell (as with os.system()). The only way to retrieve the return codes for the child processes is by using the poll() or wait() methods on the Popen3 and Popen4 classes; these are only available on Unix. This information is not available when using the popen2(), popen3(), and popen4() functions, or the equivalent functions in the os module. (Note that the tuples returned by the os module's functions are in a different order from the ones returned by the popen2 module.)
On Unix, a class defining the objects returned by the factory functions is also available. These are not used for the Windows implementation, and are not available on that platform.
See About this document... for information on suggesting changes. |