summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bb/build.py3
-rw-r--r--lib/bb/process.py46
2 files changed, 35 insertions, 14 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 2cb7a9301..bea292608 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -135,7 +135,8 @@ class LogTee(object):
def __repr__(self):
return '<LogTee {0}>'.format(self.name)
-
+ def flush(self):
+ self.outfile.flush()
def exec_func(func, d, dirs = None):
"""Execute an BB 'function'"""
diff --git a/lib/bb/process.py b/lib/bb/process.py
index b74cb1806..05b51725f 100644
--- a/lib/bb/process.py
+++ b/lib/bb/process.py
@@ -1,6 +1,8 @@
import logging
import signal
import subprocess
+import errno
+import select
logger = logging.getLogger('BitBake.Process')
@@ -68,20 +70,38 @@ def _logged_communicate(pipe, log, input):
pipe.stdin.write(input)
pipe.stdin.close()
- bufsize = 512
outdata, errdata = [], []
- while pipe.poll() is None:
- if pipe.stdout is not None:
- data = pipe.stdout.read(bufsize)
- if data is not None:
- outdata.append(data)
- log.write(data)
-
- if pipe.stderr is not None:
- data = pipe.stderr.read(bufsize)
- if data is not None:
- errdata.append(data)
- log.write(data)
+ rin = []
+
+ if pipe.stdout is not None:
+ bb.utils.nonblockingfd(pipe.stdout.fileno())
+ rin.append(pipe.stdout)
+ if pipe.stderr is not None:
+ bb.utils.nonblockingfd(pipe.stderr.fileno())
+ rin.append(pipe.stderr)
+
+ try:
+ while pipe.poll() is None:
+ rlist = rin
+ try:
+ r,w,e = select.select (rlist, [], [])
+ except OSError, e:
+ if e.errno != errno.EINTR:
+ raise
+
+ if pipe.stdout in r:
+ data = pipe.stdout.read()
+ if data is not None:
+ outdata.append(data)
+ log.write(data)
+
+ if pipe.stderr in r:
+ data = pipe.stderr.read()
+ if data is not None:
+ errdata.append(data)
+ log.write(data)
+ finally:
+ log.flush()
return ''.join(outdata), ''.join(errdata)
def run(cmd, input=None, log=None, **options):