17.1.2 Popen Objects

Instances of the Popen class have the following methods:

poll( )
Check if child process has terminated. Returns returncode attribute.

wait( )
Wait for child process to terminate. Returns returncode attribute.

communicate( input=None)
Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child.

communicate() returns a tuple (stdout, stderr).

Note: The data read is buffered in memory, so do not use this method if the data size is large or unlimited.

The following attributes are also available:

stdin
If the stdin argument is PIPE, this attribute is a file object that provides input to the child process. Otherwise, it is None.

stdout
If the stdout argument is PIPE, this attribute is a file object that provides output from the child process. Otherwise, it is None.

stderr
If the stderr argument is PIPE, this attribute is file object that provides error output from the child process. Otherwise, it is None.

pid
The process ID of the child process.

returncode
The child return code. A None value indicates that the process hasn't terminated yet. A negative value -N indicates that the child was terminated by signal N (Unix only).

See About this document... for information on suggesting changes.