summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-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()