mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Added os.popen2() and os.popen3() for non-Windows platforms.
This commit is contained in:
parent
e67d8e514f
commit
31f182e830
4 changed files with 57 additions and 4 deletions
|
@ -89,7 +89,8 @@ class Popen3:
|
|||
_active.remove(self)
|
||||
return self.sts
|
||||
|
||||
if hasattr(os, "popen2"):
|
||||
|
||||
if sys.platform[:3] == "win":
|
||||
def popen2(cmd, mode='t', bufsize=-1):
|
||||
"""Execute the shell command 'cmd' in a sub-process. If 'bufsize' is
|
||||
specified, it sets the buffer size for the I/O pipes. The file objects
|
||||
|
@ -109,7 +110,7 @@ else:
|
|||
inst = Popen3(cmd, 0, bufsize)
|
||||
return inst.fromchild, inst.tochild
|
||||
|
||||
if hasattr(os, "popen3"):
|
||||
if sys.platform[:3] == "win":
|
||||
def popen3(cmd, mode='t', bufsize=-1):
|
||||
"""Execute the shell command 'cmd' in a sub-process. If 'bufsize' is
|
||||
specified, it sets the buffer size for the I/O pipes. The file objects
|
||||
|
@ -129,7 +130,7 @@ else:
|
|||
inst = Popen3(cmd, 1, bufsize)
|
||||
return inst.fromchild, inst.tochild, inst.childerr
|
||||
|
||||
if hasattr(os, "popen4"):
|
||||
if sys.platform[:3] == "win":
|
||||
def popen4(cmd, mode='t', bufsize=-1):
|
||||
"""Execute the shell command 'cmd' in a sub-process. If 'bufsize' is
|
||||
specified, it sets the buffer size for the I/O pipes. The file objects
|
||||
|
@ -139,6 +140,7 @@ if hasattr(os, "popen4"):
|
|||
else:
|
||||
pass # not yet on unix
|
||||
|
||||
|
||||
def _test():
|
||||
cmd = "cat"
|
||||
teststr = "abc\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue