summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-08 23:37:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-09 14:27:57 +0100
commit6271fcb5896464d0c71172b02de548195191abf8 (patch)
treec7adf110c3c9148c6f4222cfee6df347acc5c902 /bitbake
parent3195cd92eb5caee027623617dbbf8790bcc76c56 (diff)
downloadpoky-6271fcb5896464d0c71172b02de548195191abf8.tar.gz
bitbake: bitbake-worker: Handle SIGKILL of parent gracefully
If we SIGKILL cooker (the parent process), ensure the worker notices and shuts down gracefully. To do this: * trigger the sigterm handler if the parent exits * ensure broken pipe writes don't trigger backtraces which interfer with other exit work * notice if our command pipe is broken due to EOF and sigterm if so (Bitbake rev: c43d6a8d711db8d3bd9a1976b9f8e3efdb4cb4ae) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-worker9
1 files changed, 7 insertions, 2 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index c429dc76d7..5f6543b7e9 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -80,7 +80,7 @@ def worker_flush():
80 written = os.write(worker_pipe, worker_queue) 80 written = os.write(worker_pipe, worker_queue)
81 worker_queue = worker_queue[written:] 81 worker_queue = worker_queue[written:]
82 except (IOError, OSError) as e: 82 except (IOError, OSError) as e:
83 if e.errno != errno.EAGAIN: 83 if e.errno != errno.EAGAIN and e.errno != errno.EPIPE:
84 raise 84 raise
85 85
86def worker_child_fire(event, d): 86def worker_child_fire(event, d):
@@ -158,6 +158,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat
158 signal.signal(signal.SIGTERM, sigterm_handler) 158 signal.signal(signal.SIGTERM, sigterm_handler)
159 # Let SIGHUP exit as SIGTERM 159 # Let SIGHUP exit as SIGTERM
160 signal.signal(signal.SIGHUP, sigterm_handler) 160 signal.signal(signal.SIGHUP, sigterm_handler)
161 bb.utils.signal_on_parent_exit("SIGTERM")
161 162
162 # Save out the PID so that the event can include it the 163 # Save out the PID so that the event can include it the
163 # events 164 # events
@@ -297,7 +298,11 @@ class BitbakeWorker(object):
297 (ready, _, _) = select.select([self.input] + [i.input for i in self.build_pipes.values()], [] , [], 1) 298 (ready, _, _) = select.select([self.input] + [i.input for i in self.build_pipes.values()], [] , [], 1)
298 if self.input in ready: 299 if self.input in ready:
299 try: 300 try:
300 self.queue = self.queue + self.input.read() 301 r = self.input.read()
302 if len(r) == 0:
303 # EOF on pipe, server must have terminated
304 self.sigterm_exception(signal.SIGTERM, None)
305 self.queue = self.queue + r
301 except (OSError, IOError): 306 except (OSError, IOError):
302 pass 307 pass
303 if len(self.queue): 308 if len(self.queue):