STDIN, STDOUT = 0, 1
while not process.poll() is None:
    out = process.stdout.read(1)
if not out:
    break
try:
    fds = select.select([STDIN], [], [])[0]
except select.error:
    pass
else:
    if STDIN in fds:
        data = os.read(STDIN, 1024)
if data_requested:
    process.stdin.write(data)
Python, trying to get input from subprocess?