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:
+9
-1
@@ -91,8 +91,9 @@ 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 ]
|
||||||
|
if event & POLLIN:
|
||||||
data = f.read( 1024 )
|
data = f.read( 1024 )
|
||||||
if echo:
|
if echo:
|
||||||
output( data )
|
output( data )
|
||||||
@@ -104,6 +105,13 @@ def errRun( *cmd, **kwargs ):
|
|||||||
err += data
|
err += data
|
||||||
if data == '':
|
if data == '':
|
||||||
errDone = True
|
errDone = True
|
||||||
|
elif event & POLLHUP:
|
||||||
|
if f == popen.stdout:
|
||||||
|
outDone = True
|
||||||
|
elif f == popen.stderr:
|
||||||
|
errDone = True
|
||||||
|
poller.unregister( fd )
|
||||||
|
|
||||||
returncode = popen.wait()
|
returncode = popen.wait()
|
||||||
return out, err, returncode
|
return out, err, returncode
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user