8.18 popen2 -- Subprocesses with accessible I/O streams

Availability: Unix.

This module allows you to spawn processes and connect their input/output/error pipes and obtain their return codes under Unix. Similar functionality exists for Windows platforms using the win32pipe module provided as part of Mark Hammond's Windows extensions.

The primary interface offered by this module is a pair of factory functions:

popen2 (cmd[, bufsize])
Executes cmd as a sub-process. If bufsize is specified, it specifies the buffer size for the I/O pipes. Returns the file objects (child_stdout, child_stdin).

popen3 (cmd[, bufsize])
Executes cmd as a sub-process. If bufsize is specified, it specifies the buffer size for the I/O pipes. Returns the file objects (child_stdout, child_stdin, child_stderr).

The class defining the objects returned by the factory functions is also available:

Popen3 (cmd[, capturestderr[, bufsize]])
This class represents a child process. Normally, Popen3 instances are created using the factory functions described above.

If not using one off the helper functions to create Popen3 objects, the parameter cmd is the shell command to execute in a sub-process. The capturestderr flag, if true, specifies that the object should capture standard error output of the child process. The default is false. If the bufsize parameter is specified, it specifies the size of the I/O buffers to/from the child process.



Send comments on this document to python-docs@python.org.