1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

bitbake: bitbake:process: flush stderr/stdout to log

When a process terminates, some messages may still remain in stdout or
stderr and do not make it into the log file.
In addition, the messages that do make it to the log file may end up in
the log file in incorrect order.
This patch flushes all messages into the log file after the
process terminates. Some additional log flushing is also needed
to keep the various messages showing up in the log file in proper order.

[YOCTO#10785]

(Bitbake rev: 1f6e6aa8262369eafc3bbf9f01f8d981f90becdf)

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Juro Bystricky
2017-06-13 09:21:54 -07:00
committed by Richard Purdie
parent de5776c41a
commit 06e9b44f97
+12 -5
View File
@@ -94,17 +94,19 @@ def _logged_communicate(pipe, log, input, extrafiles):
if data is not None: if data is not None:
func(data) func(data)
try: def read_all_pipes(log, rin, outdata, errdata):
while pipe.poll() is None:
rlist = rin rlist = rin
stdoutbuf = b"" stdoutbuf = b""
stderrbuf = b"" stderrbuf = b""
try: try:
r,w,e = select.select (rlist, [], [], 1) r,w,e = select.select (rlist, [], [], 1)
except OSError as e: except OSError as e:
if e.errno != errno.EINTR: if e.errno != errno.EINTR:
raise raise
readextras(r)
if pipe.stdout in r: if pipe.stdout in r:
data = stdoutbuf + pipe.stdout.read() data = stdoutbuf + pipe.stdout.read()
if data is not None and len(data) > 0: if data is not None and len(data) > 0:
@@ -112,6 +114,7 @@ def _logged_communicate(pipe, log, input, extrafiles):
data = data.decode("utf-8") data = data.decode("utf-8")
outdata.append(data) outdata.append(data)
log.write(data) log.write(data)
log.flush()
stdoutbuf = b"" stdoutbuf = b""
except UnicodeDecodeError: except UnicodeDecodeError:
stdoutbuf = data stdoutbuf = data
@@ -123,17 +126,21 @@ def _logged_communicate(pipe, log, input, extrafiles):
data = data.decode("utf-8") data = data.decode("utf-8")
errdata.append(data) errdata.append(data)
log.write(data) log.write(data)
log.flush()
stderrbuf = b"" stderrbuf = b""
except UnicodeDecodeError: except UnicodeDecodeError:
stderrbuf = data stderrbuf = data
readextras(r) try:
# Read all pipes while the process is open
while pipe.poll() is None:
read_all_pipes(log, rin, outdata, errdata)
# Pocess closed, drain all pipes...
read_all_pipes(log, rin, outdata, errdata)
finally: finally:
log.flush() log.flush()
readextras([fobj for fobj, _ in extrafiles])
if pipe.stdout is not None: if pipe.stdout is not None:
pipe.stdout.close() pipe.stdout.close()
if pipe.stderr is not None: if pipe.stderr is not None: