6 Jun 2017
I misunderstood how
stdinwas only read when a child process demanded an input.
It turns out that a process is always reading
stdin. We can send an input to a process at any time. The process will read an input when it needs the input. This means we can type
yes before we are being prompted.
Python seems to proxy
stdin for us already. Therefore, we don't need to assign
sys.stdin. Here's an example:
import sys import subprocess proc = subprocess.Popen('gdb', shell=True) print proc.communicate() print print print 'Run another gdb process. This proves that we can just re-use sys.stdin.' print print proc = subprocess.Popen('gdb', shell=True) print proc.communicate()
gdb is an interactive debugger. This code seems to work fine.