mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Follow-up to #4488: document PIPE and STDOUT properly.
This commit is contained in:
parent
826f3fefe5
commit
f5d5a66349
1 changed files with 33 additions and 18 deletions
|
@ -73,13 +73,13 @@ This module defines one class called :class:`Popen`:
|
||||||
specified by the :envvar:`COMSPEC` environment variable.
|
specified by the :envvar:`COMSPEC` environment variable.
|
||||||
|
|
||||||
*stdin*, *stdout* and *stderr* specify the executed programs' standard input,
|
*stdin*, *stdout* and *stderr* specify the executed programs' standard input,
|
||||||
standard output and standard error file handles, respectively. Valid values are
|
standard output and standard error file handles, respectively. Valid values
|
||||||
``PIPE``, an existing file descriptor (a positive integer), an existing file
|
are :data:`PIPE`, an existing file descriptor (a positive integer), an
|
||||||
object, and ``None``. ``PIPE`` indicates that a new pipe to the child should be
|
existing file object, and ``None``. :data:`PIPE` indicates that a new pipe
|
||||||
created. With ``None``, no redirection will occur; the child's file handles
|
to the child should be created. With ``None``, no redirection will occur;
|
||||||
will be inherited from the parent. Additionally, *stderr* can be ``STDOUT``,
|
the child's file handles will be inherited from the parent. Additionally,
|
||||||
which indicates that the stderr data from the applications should be captured
|
*stderr* can be :data:`STDOUT`, which indicates that the stderr data from the
|
||||||
into the same file handle as for stdout.
|
applications should be captured into the same file handle as for stdout.
|
||||||
|
|
||||||
If *preexec_fn* is set to a callable object, this object will be called in the
|
If *preexec_fn* is set to a callable object, this object will be called in the
|
||||||
child process just before the child is executed. (Unix only)
|
child process just before the child is executed. (Unix only)
|
||||||
|
@ -119,6 +119,20 @@ This module defines one class called :class:`Popen`:
|
||||||
of the main window and priority for the new process. (Windows only)
|
of the main window and priority for the new process. (Windows only)
|
||||||
|
|
||||||
|
|
||||||
|
.. data:: PIPE
|
||||||
|
|
||||||
|
Special value that can be used as the *stdin*, *stdout* or *stderr* argument
|
||||||
|
to :class:`Popen` and indicates that a pipe to the standard stream should be
|
||||||
|
opened.
|
||||||
|
|
||||||
|
|
||||||
|
.. data:: STDOUT
|
||||||
|
|
||||||
|
Special value that can be used as the *stderr* argument to :class:`Popen` and
|
||||||
|
indicates that standard error should go into the same handle as standard
|
||||||
|
output.
|
||||||
|
|
||||||
|
|
||||||
Convenience Functions
|
Convenience Functions
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -285,20 +299,21 @@ The following attributes are also available:
|
||||||
|
|
||||||
.. attribute:: Popen.stdin
|
.. attribute:: Popen.stdin
|
||||||
|
|
||||||
If the *stdin* argument is ``PIPE``, this attribute is a file object that
|
If the *stdin* argument was :data:`PIPE`, this attribute is a file object
|
||||||
provides input to the child process. Otherwise, it is ``None``.
|
that provides input to the child process. Otherwise, it is ``None``.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: Popen.stdout
|
.. attribute:: Popen.stdout
|
||||||
|
|
||||||
If the *stdout* argument is ``PIPE``, this attribute is a file object that
|
If the *stdout* argument was :data:`PIPE`, this attribute is a file object
|
||||||
provides output from the child process. Otherwise, it is ``None``.
|
that provides output from the child process. Otherwise, it is ``None``.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: Popen.stderr
|
.. attribute:: Popen.stderr
|
||||||
|
|
||||||
If the *stderr* argument is ``PIPE``, this attribute is file object that
|
If the *stderr* argument was :data:`PIPE`, this attribute is a file object
|
||||||
provides error output from the child process. Otherwise, it is ``None``.
|
that provides error output from the child process. Otherwise, it is
|
||||||
|
``None``.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: Popen.pid
|
.. attribute:: Popen.pid
|
||||||
|
@ -478,15 +493,15 @@ Replacing functions from the popen2 module
|
||||||
stdin=PIPE, stdout=PIPE, close_fds=True)
|
stdin=PIPE, stdout=PIPE, close_fds=True)
|
||||||
(child_stdout, child_stdin) = (p.stdout, p.stdin)
|
(child_stdout, child_stdin) = (p.stdout, p.stdin)
|
||||||
|
|
||||||
The popen2.Popen3 and popen2.Popen4 basically works as subprocess.Popen, except
|
:class:`popen2.Popen3` and :class:`popen2.Popen4` basically work as
|
||||||
that:
|
:class:`subprocess.Popen`, except that:
|
||||||
|
|
||||||
* subprocess.Popen raises an exception if the execution fails
|
* :class:`Popen` raises an exception if the execution fails.
|
||||||
|
|
||||||
* the *capturestderr* argument is replaced with the *stderr* argument.
|
* the *capturestderr* argument is replaced with the *stderr* argument.
|
||||||
|
|
||||||
* stdin=PIPE and stdout=PIPE must be specified.
|
* ``stdin=PIPE`` and ``stdout=PIPE`` must be specified.
|
||||||
|
|
||||||
* popen2 closes all file descriptors by default, but you have to specify
|
* popen2 closes all file descriptors by default, but you have to specify
|
||||||
close_fds=True with subprocess.Popen.
|
``close_fds=True`` with :class:`Popen`.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue