1edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep"""Spawn a command with pipes to its stdin, stdout, and optionally stderr. 2edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 3edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander StoepThe normal os.popen(cmd, mode) call spawns a shell command and provides a 4edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepfile interface to just the input or output of the process depending on 5edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepwhether mode is 'r' or 'w'. This module provides the functions popen2(cmd) 6edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepand popen3(cmd) which return two or three pipes to the spawned command. 7edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep""" 8edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 9edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepimport os 10edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepimport sys 11edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepimport warnings 12edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepwarnings.warn("The popen2 module is deprecated. Use the subprocess module.", 13edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep DeprecationWarning, stacklevel=2) 14edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 15edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep__all__ = ["popen2", "popen3", "popen4"] 16edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 17edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoeptry: 18edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep MAXFD = os.sysconf('SC_OPEN_MAX') 19edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepexcept (AttributeError, ValueError): 20edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep MAXFD = 256 21edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 22edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep_active = [] 23edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 24edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepdef _cleanup(): 25edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep for inst in _active[:]: 26edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if inst.poll(_deadstate=sys.maxint) >= 0: 27edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep try: 28edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep _active.remove(inst) 29edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep except ValueError: 30edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # This can happen if two threads create a new Popen instance. 31edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # It's harmless that it was already removed, so ignore. 32edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep pass 33edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 34edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepclass Popen3: 35edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Class representing a child process. Normally, instances are created 36edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep internally by the functions popen2() and popen3().""" 37edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 38edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep sts = -1 # Child not completed yet 39edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 40edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def __init__(self, cmd, capturestderr=False, bufsize=-1): 41edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """The parameter 'cmd' is the shell command to execute in a 42edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments 43edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep will be passed directly to the program without shell intervention (as 44edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep with os.spawnv()). If 'cmd' is a string it will be passed to the shell 45edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep (as with os.system()). The 'capturestderr' flag, if true, specifies 46edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep that the object should capture standard error output of the child 47edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep process. The default is false. If the 'bufsize' parameter is 48edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep specified, it specifies the size of the I/O buffers to/from the child 49edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep process.""" 50edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep _cleanup() 51edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.cmd = cmd 52edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep p2cread, p2cwrite = os.pipe() 53edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep c2pread, c2pwrite = os.pipe() 54edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if capturestderr: 55edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep errout, errin = os.pipe() 56edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.pid = os.fork() 57edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if self.pid == 0: 58edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # Child 59edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(p2cread, 0) 60edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(c2pwrite, 1) 61edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if capturestderr: 62edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(errin, 2) 63edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self._run_child(cmd) 64edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.close(p2cread) 65edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.tochild = os.fdopen(p2cwrite, 'w', bufsize) 66edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.close(c2pwrite) 67edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.fromchild = os.fdopen(c2pread, 'r', bufsize) 68edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if capturestderr: 69edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.close(errin) 70edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.childerr = os.fdopen(errout, 'r', bufsize) 71edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep else: 72edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.childerr = None 73edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 74edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def __del__(self): 75edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # In case the child hasn't been waited on, check if it's done. 76edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.poll(_deadstate=sys.maxint) 77edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if self.sts < 0: 78edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if _active is not None: 79edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # Child is still running, keep us alive until we can wait on it. 80edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep _active.append(self) 81edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 82edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def _run_child(self, cmd): 83edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if isinstance(cmd, basestring): 84edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep cmd = ['/bin/sh', '-c', cmd] 85edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.closerange(3, MAXFD) 86edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep try: 87edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.execvp(cmd[0], cmd) 88edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep finally: 89edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os._exit(1) 90edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 91edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def poll(self, _deadstate=None): 92edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Return the exit status of the child process if it has finished, 93edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep or -1 if it hasn't finished yet.""" 94edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if self.sts < 0: 95edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep try: 96edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep pid, sts = os.waitpid(self.pid, os.WNOHANG) 97edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # pid will be 0 if self.pid hasn't terminated 98edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if pid == self.pid: 99edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.sts = sts 100edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep except os.error: 101edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if _deadstate is not None: 102edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.sts = _deadstate 103edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return self.sts 104edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 105edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def wait(self): 106edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Wait for and return the exit status of the child process.""" 107edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if self.sts < 0: 108edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep pid, sts = os.waitpid(self.pid, 0) 109edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # This used to be a test, but it is believed to be 110edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # always true, so I changed it to an assertion - mvl 111edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep assert pid == self.pid 112edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.sts = sts 113edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return self.sts 114edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 115edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 116edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepclass Popen4(Popen3): 117edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep childerr = None 118edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 119edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def __init__(self, cmd, bufsize=-1): 120edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep _cleanup() 121edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.cmd = cmd 122edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep p2cread, p2cwrite = os.pipe() 123edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep c2pread, c2pwrite = os.pipe() 124edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.pid = os.fork() 125edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep if self.pid == 0: 126edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # Child 127edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(p2cread, 0) 128edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(c2pwrite, 1) 129edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.dup2(c2pwrite, 2) 130edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self._run_child(cmd) 131edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.close(p2cread) 132edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.tochild = os.fdopen(p2cwrite, 'w', bufsize) 133edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep os.close(c2pwrite) 134edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep self.fromchild = os.fdopen(c2pread, 'r', bufsize) 135edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 136edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 137edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepif sys.platform[:3] == "win" or sys.platform == "os2emx": 138edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep # Some things don't make sense on non-Unix platforms. 139edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep del Popen3, Popen4 140edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 141edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen2(cmd, bufsize=-1, mode='t'): 142edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 143edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 144edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 145edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 146edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 147edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout, child_stdin) are returned.""" 148edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep w, r = os.popen2(cmd, mode, bufsize) 149edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return r, w 150edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 151edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen3(cmd, bufsize=-1, mode='t'): 152edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 153edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 154edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 155edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 156edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 157edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout, child_stdin, child_stderr) are returned.""" 158edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep w, r, e = os.popen3(cmd, mode, bufsize) 159edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return r, w, e 160edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 161edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen4(cmd, bufsize=-1, mode='t'): 162edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 163edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 164edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 165edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 166edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 167edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout_stderr, child_stdin) are returned.""" 168edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep w, r = os.popen4(cmd, mode, bufsize) 169edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return r, w 170edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoepelse: 171edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen2(cmd, bufsize=-1, mode='t'): 172edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 173edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 174edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 175edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 176edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 177edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout, child_stdin) are returned.""" 178edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep inst = Popen3(cmd, False, bufsize) 179edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return inst.fromchild, inst.tochild 180edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 181edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen3(cmd, bufsize=-1, mode='t'): 182edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 183edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 184edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 185edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 186edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 187edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout, child_stdin, child_stderr) are returned.""" 188edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep inst = Popen3(cmd, True, bufsize) 189edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return inst.fromchild, inst.tochild, inst.childerr 190edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 191edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep def popen4(cmd, bufsize=-1, mode='t'): 192edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may 193edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep be a sequence, in which case arguments will be passed directly to the 194edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep program without shell intervention (as with os.spawnv()). If 'cmd' is a 195edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep string it will be passed to the shell (as with os.system()). If 196edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 'bufsize' is specified, it sets the buffer size for the I/O pipes. The 197edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep file objects (child_stdout_stderr, child_stdin) are returned.""" 198edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep inst = Popen4(cmd, bufsize) 199edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep return inst.fromchild, inst.tochild 200edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep 201edbb763a2b63074cd468a5d33a17908b2cc0654Jeff Vander Stoep __all__.extend(["Popen3", "Popen4"]) 202