Very puzzled by this. When using Popen, if only using stdout or stderr the following code works:
def run(self):
self.externalProcess = subprocess.Popen(['./external_process.out 1>&2'], shell=True, stderr=subprocess.PIPE)
while self.externalBinary.poll() is None:
print('Still running')
print('Done running')
I'm using the stderr file descriptor because I'm monitoring the process output real time in a GUI and stderr is unbuffered. See my other question for more background on that mess: Python capture stdout from subprocess line by line
The problem I'm having here is that as soon as I add stdin to allow user input to be passed to the external process it starts acting as though stdout is buffered again:
def run(self):
self.externalProcess = subprocess.Popen(['./external_process.out 1>&2'], shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
while self.externalBinary.poll() is None:
print('Still running')
print('Done running')
My question is why does stdin appear to be affecting stdout and stderr?