diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/build.py | 3 | ||||
-rw-r--r-- | bitbake/lib/bb/process.py | 46 |
2 files changed, 35 insertions, 14 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 2cb7a9301b..bea2926085 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -135,7 +135,8 @@ class LogTee(object): | |||
135 | 135 | ||
136 | def __repr__(self): | 136 | def __repr__(self): |
137 | return '<LogTee {0}>'.format(self.name) | 137 | return '<LogTee {0}>'.format(self.name) |
138 | 138 | def flush(self): | |
139 | self.outfile.flush() | ||
139 | 140 | ||
140 | def exec_func(func, d, dirs = None): | 141 | def exec_func(func, d, dirs = None): |
141 | """Execute an BB 'function'""" | 142 | """Execute an BB 'function'""" |
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py index b74cb18066..05b51725f1 100644 --- a/bitbake/lib/bb/process.py +++ b/bitbake/lib/bb/process.py | |||
@@ -1,6 +1,8 @@ | |||
1 | import logging | 1 | import logging |
2 | import signal | 2 | import signal |
3 | import subprocess | 3 | import subprocess |
4 | import errno | ||
5 | import select | ||
4 | 6 | ||
5 | logger = logging.getLogger('BitBake.Process') | 7 | logger = logging.getLogger('BitBake.Process') |
6 | 8 | ||
@@ -68,20 +70,38 @@ def _logged_communicate(pipe, log, input): | |||
68 | pipe.stdin.write(input) | 70 | pipe.stdin.write(input) |
69 | pipe.stdin.close() | 71 | pipe.stdin.close() |
70 | 72 | ||
71 | bufsize = 512 | ||
72 | outdata, errdata = [], [] | 73 | outdata, errdata = [], [] |
73 | while pipe.poll() is None: | 74 | rin = [] |
74 | if pipe.stdout is not None: | 75 | |
75 | data = pipe.stdout.read(bufsize) | 76 | if pipe.stdout is not None: |
76 | if data is not None: | 77 | bb.utils.nonblockingfd(pipe.stdout.fileno()) |
77 | outdata.append(data) | 78 | rin.append(pipe.stdout) |
78 | log.write(data) | 79 | if pipe.stderr is not None: |
79 | 80 | bb.utils.nonblockingfd(pipe.stderr.fileno()) | |
80 | if pipe.stderr is not None: | 81 | rin.append(pipe.stderr) |
81 | data = pipe.stderr.read(bufsize) | 82 | |
82 | if data is not None: | 83 | try: |
83 | errdata.append(data) | 84 | while pipe.poll() is None: |
84 | log.write(data) | 85 | rlist = rin |
86 | try: | ||
87 | r,w,e = select.select (rlist, [], []) | ||
88 | except OSError, e: | ||
89 | if e.errno != errno.EINTR: | ||
90 | raise | ||
91 | |||
92 | if pipe.stdout in r: | ||
93 | data = pipe.stdout.read() | ||
94 | if data is not None: | ||
95 | outdata.append(data) | ||
96 | log.write(data) | ||
97 | |||
98 | if pipe.stderr in r: | ||
99 | data = pipe.stderr.read() | ||
100 | if data is not None: | ||
101 | errdata.append(data) | ||
102 | log.write(data) | ||
103 | finally: | ||
104 | log.flush() | ||
85 | return ''.join(outdata), ''.join(errdata) | 105 | return ''.join(outdata), ''.join(errdata) |
86 | 106 | ||
87 | def run(cmd, input=None, log=None, **options): | 107 | def run(cmd, input=None, log=None, **options): |