New submission from Robert O'Callahan: Popen() ought to support redirection to/from more file descriptors than 0, 1, and 2 when spawning processes. A clear use case is here: http://stackoverflow.com/questions/6050187/write-to-file-descriptor-3-of-a-python-subprocess-popen-object
Instead of messing around with os.open() and os.close() calls, my proposed API for Popen would be to accept keyword arguments fdN that would take the same type of values as the stdin, stdout, stderr arguments. Conflicting fd0 and stdin arguments would throw an exception. So the smelly code in the above SO question would be changed to: cmd='gpg --passphrase-fd {fd} -c'.format(fd=fd) with open('passphrase.txt','r') as fd3_fh: with open('filename.txt','r') as stdin_fh: with open('filename.gpg','w') as stdout_fh: proc=subprocess.Popen(shlex.split(cmd), stdin=stdin_fh, stdout=stdout_fh, fd3=fd3_fh) proc.communicate() ---------- components: Library (Lib) messages: 193646 nosy: ropoctorix priority: normal severity: normal status: open title: subprocess.Popen support for redirection of arbitrary file descriptors type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18544> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com