Fix polling in errRun

It's tricky to get this right, but basically we want to read
if there is something to read; if not, we want to check for
EOF.
This commit is contained in:
Bob Lantz
2015-01-23 16:41:29 -08:00
parent ef59cd88dc
commit 28ce13d18e
+18 -10
View File
@@ -91,19 +91,27 @@ def errRun( *cmd, **kwargs ):
errDone = False errDone = False
while not outDone or not errDone: while not outDone or not errDone:
readable = poller.poll() readable = poller.poll()
for fd, _event in readable: for fd, event in readable:
f = fdtofile[ fd ] f = fdtofile[ fd ]
data = f.read( 1024 ) if event & POLLIN:
if echo: data = f.read( 1024 )
output( data ) if echo:
if f == popen.stdout: output( data )
out += data if f == popen.stdout:
if data == '': out += data
if data == '':
outDone = True
elif f == popen.stderr:
err += data
if data == '':
errDone = True
elif event & POLLHUP:
if f == popen.stdout:
outDone = True outDone = True
elif f == popen.stderr: elif f == popen.stderr:
err += data
if data == '':
errDone = True errDone = True
poller.unregister( fd )
returncode = popen.wait() returncode = popen.wait()
return out, err, returncode return out, err, returncode