Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8a9db997
Commit
8a9db997
authored
Sep 28, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated documentation relating to the various flavors of popen[234]()
for Windows & Unix.
parent
18b9b93d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
24 deletions
+79
-24
Doc/lib/libos.tex
Doc/lib/libos.tex
+30
-0
Doc/lib/libpopen2.tex
Doc/lib/libpopen2.tex
+49
-24
No files found.
Doc/lib/libos.tex
View file @
8a9db997
...
...
@@ -296,6 +296,36 @@ Availability: \UNIX{}.
\end{funcdesc}
For each of these
\function
{
popen()
}
variants, if
\var
{
bufsize
}
is
specified, it specifies the buffer size for the I/O pipes.
\var
{
mode
}
, if provided, should be the string
\code
{
'b'
}
or
\code
{
't'
}
; on Windows this is needed to determine whether the file
objects should be opened in binary or text mode. The default value
for
\var
{
mode
}
is
\code
{
't'
}
.
\begin{funcdesc}
{
popen2
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdin
}
,
\var
{
child
_
stdout
}
)
}
.
\versionadded
{
2.0
}
\end{funcdesc}
\begin{funcdesc}
{
popen3
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdin
}
,
\var
{
child
_
stdout
}
,
\var
{
child
_
stderr
}
)
}
.
\versionadded
{
2.0
}
\end{funcdesc}
\begin{funcdesc}
{
popen4
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdin
}
,
\var
{
child
_
stdout
_
and
_
stderr
}
)
}
.
\versionadded
{
2.0
}
\end{funcdesc}
This functionality is also available in the
\refmodule
{
popen2
}
module
using functions of the same names, but the return values of those
functions have a different order.
\subsection
{
File Descriptor Operations
\label
{
os-fd-ops
}}
These functions operate on I/O streams referred to
...
...
Doc/lib/libpopen2.tex
View file @
8a9db997
...
...
@@ -2,39 +2,53 @@
Subprocesses with accessible I/O streams
}
\declaremodule
{
standard
}{
popen2
}
\platform
{
Unix
}
\platform
{
Unix
, Windows
}
\modulesynopsis
{
Subprocesses with accessible standard I/O streams.
}
\sectionauthor
{
Drew Csillag
}{
drew
_
csillag@geocities.com
}
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
\module
{
win32pipe
}
module provided as part of Mark Hammond's Windows
extensions.
This module allows you to spawn processes and connect to their
input/output/error pipes and obtain their return codes under
\UNIX
{}
and Windows.
The primary interface offered by this module is a pair of factory
functions:
Note that starting with Python 2.0, this functionality is available
using functions from the
\refmodule
{
os
}
module which have the same
names as the factory functions here, but the order of the return
values is more intuitive in the
\refmodule
{
os
}
module variants.
\begin{funcdesc}
{
popen2
}{
cmd
\optional
{
, bufsize
}}
Executes
\var
{
cmd
}
as a sub-process. If
\var
{
bufsize
}
is specified,
it specifies the buffer size for the I/O pipes. Returns the file
objects
\code
{
(
\var
{
child
_
stdout
}
,
\var
{
child
_
stdin
}
)
}
.
The primary interface offered by this module is a trio of factory
functions. For each of these, if
\var
{
bufsize
}
is specified,
it specifies the buffer size for the I/O pipes.
\var
{
mode
}
, if
provided, should be the string
\code
{
'b'
}
or
\code
{
't'
}
; on Windows
this is needed to determine whether the file objects should be opened
in binary or text mode. The default value for
\var
{
mode
}
is
\code
{
't'
}
.
\begin{funcdesc}
{
popen2
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdout
}
,
\var
{
child
_
stdin
}
)
}
.
\end{funcdesc}
\begin{funcdesc}
{
popen3
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdout
}
,
\var
{
child
_
stdin
}
,
\var
{
child
_
stderr
}
)
}
.
\end{funcdesc}
\begin{funcdesc}
{
popen3
}{
cmd
\optional
{
, bufsize
}}
Executes
\var
{
cmd
}
as a sub-process. If
\var
{
bufsize
}
is specified,
it specifies the buffer size for the I/O pipes. Returns the file
objects
\code
{
(
\var
{
child
_
stdout
}
,
\var
{
child
_
stdin
}
,
\var
{
child
_
stderr
}
)
}
.
\begin{funcdesc}
{
popen4
}{
cmd
\optional
{
, bufsize
\optional
{
, mode
}}}
Executes
\var
{
cmd
}
as a sub-process. Returns the file objects
\code
{
(
\var
{
child
_
stdout
_
and
_
stderr
}
,
\var
{
child
_
stdin
}
)
}
.
\versionadded
{
2.0
}
\end{funcdesc}
The class defining the objects returned by the factory functions is
also available:
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.
\begin{classdesc}
{
Popen3
}{
cmd
\optional
{
, capturestderr
\optional
{
, bufsize
}}}
This class represents a child process. Normally,
\class
{
Popen3
}
instances are created using the factory functions described above.
instances are created using the
\function
{
popen2()
}
and
\function
{
popen3()
}
factory functions described above.
If not using one off the helper functions to create
\class
{
Popen3
}
objects, the parameter
\var
{
cmd
}
is the shell command to execute in a
...
...
@@ -44,10 +58,18 @@ The default is false. If the \var{bufsize} parameter is specified, it
specifies the size of the I/O buffers to/from the child process.
\end{classdesc}
\begin{classdesc}
{
Popen4
}{
cmd
\optional
{
, bufsize
}}
Similar to
\class
{
Popen3
}
, but always captures standard error into the
same file object as standard output. These are typically created
using
\function
{
popen4()
}
.
\versionadded
{
2.0
}
\end{classdesc}
\subsection
{
Popen3 Objects
\label
{
popen3-objects
}}
\subsection
{
Popen3
and Popen4
Objects
\label
{
popen3-objects
}}
Instances of the
\class
{
Popen3
}
class have the following methods:
Instances of the
\class
{
Popen3
}
and
\class
{
Popen4
}
classes have the
following methods:
\begin{methoddesc}
{
poll
}{}
Returns
\code
{
-1
}
if child process hasn't completed yet, or its return
...
...
@@ -59,10 +81,12 @@ Waits for and returns the return code of the child process.
\end{methoddesc}
The following attributes
of
\class
{
Popen3
}
objects
are also available:
The following attributes are also available:
\begin{memberdesc}
{
fromchild
}
A file object that provides output from the child process.
A file object that provides output from the child process. For
\class
{
Popen4
}
instances, this will provide both the standard output
and standard error streams.
\end{memberdesc}
\begin{memberdesc}
{
tochild
}
...
...
@@ -72,6 +96,7 @@ A file object that provides input to the child process.
\begin{memberdesc}
{
childerr
}
Where the standard error from the child process goes is
\var
{
capturestderr
}
was true for the constructor, or
\code
{
None
}
.
This will always be
\code
{
None
}
for
\class
{
Popen4
}
instances.
\end{memberdesc}
\begin{memberdesc}
{
pid
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment