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
while not outDone or not errDone:
readable = poller.poll()
for fd, _event in readable:
for fd, event in readable:
f = fdtofile[ fd ]
data = f.read( 1024 )
if echo:
output( data )
if f == popen.stdout:
out += data
if data == '':
if event & POLLIN:
data = f.read( 1024 )
if echo:
output( data )
if f == popen.stdout:
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
elif f == popen.stderr:
err += data
if data == '':
elif f == popen.stderr:
errDone = True
poller.unregister( fd )
returncode = popen.wait()
return out, err, returncode