summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2017-06-13 09:21:54 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-14 14:54:24 +0100
commit06e9b44f97a4ba5552d2b2ad1d10acd1871ac1ce (patch)
tree487c202d2f5740c9d8a2aada81e1513e5f2c82f9
parentde5776c41aeb2d0a73942deaeaa43a3b5bb80a1e (diff)
downloadpoky-06e9b44f97a4ba5552d2b2ad1d10acd1871ac1ce.tar.gz
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>
-rw-r--r--bitbake/lib/bb/process.py79
1 files changed, 43 insertions, 36 deletions
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py
index a4a559982c..e69697cb68 100644
--- a/bitbake/lib/bb/process.py
+++ b/bitbake/lib/bb/process.py
@@ -94,45 +94,52 @@ def _logged_communicate(pipe, log, input, extrafiles):
94 if data is not None: 94 if data is not None:
95 func(data) 95 func(data)
96 96
97 def read_all_pipes(log, rin, outdata, errdata):
98 rlist = rin
99 stdoutbuf = b""
100 stderrbuf = b""
101
102 try:
103 r,w,e = select.select (rlist, [], [], 1)
104 except OSError as e:
105 if e.errno != errno.EINTR:
106 raise
107
108 readextras(r)
109
110 if pipe.stdout in r:
111 data = stdoutbuf + pipe.stdout.read()
112 if data is not None and len(data) > 0:
113 try:
114 data = data.decode("utf-8")
115 outdata.append(data)
116 log.write(data)
117 log.flush()
118 stdoutbuf = b""
119 except UnicodeDecodeError:
120 stdoutbuf = data
121
122 if pipe.stderr in r:
123 data = stderrbuf + pipe.stderr.read()
124 if data is not None and len(data) > 0:
125 try:
126 data = data.decode("utf-8")
127 errdata.append(data)
128 log.write(data)
129 log.flush()
130 stderrbuf = b""
131 except UnicodeDecodeError:
132 stderrbuf = data
133
97 try: 134 try:
135 # Read all pipes while the process is open
98 while pipe.poll() is None: 136 while pipe.poll() is None:
99 rlist = rin 137 read_all_pipes(log, rin, outdata, errdata)
100 stdoutbuf = b""
101 stderrbuf = b""
102 try:
103 r,w,e = select.select (rlist, [], [], 1)
104 except OSError as e:
105 if e.errno != errno.EINTR:
106 raise
107
108 if pipe.stdout in r:
109 data = stdoutbuf + pipe.stdout.read()
110 if data is not None and len(data) > 0:
111 try:
112 data = data.decode("utf-8")
113 outdata.append(data)
114 log.write(data)
115 stdoutbuf = b""
116 except UnicodeDecodeError:
117 stdoutbuf = data
118
119 if pipe.stderr in r:
120 data = stderrbuf + pipe.stderr.read()
121 if data is not None and len(data) > 0:
122 try:
123 data = data.decode("utf-8")
124 errdata.append(data)
125 log.write(data)
126 stderrbuf = b""
127 except UnicodeDecodeError:
128 stderrbuf = data
129
130 readextras(r)
131
132 finally:
133 log.flush()
134 138
135 readextras([fobj for fobj, _ in extrafiles]) 139 # Pocess closed, drain all pipes...
140 read_all_pipes(log, rin, outdata, errdata)
141 finally:
142 log.flush()
136 143
137 if pipe.stdout is not None: 144 if pipe.stdout is not None:
138 pipe.stdout.close() 145 pipe.stdout.close()