Currently if bitbake-worker handles a SIGTERM, it leaves the child
processes to complete or hang. It shouldn't do this so hook the SIGTERM
event and gracefully shutdown any children.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
self.build_pids = {}
self.build_pipes = {}
+ signal.signal(signal.SIGTERM, self.sigterm_exception)
+
+ def sigterm_exception(self, signum, stackframe):
+ bb.warn("Worker recieved SIGTERM, shutting down...")
+ self.handle_finishnow(None)
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+ os.kill(os.getpid(), signal.SIGTERM)
+
def serve(self):
while True:
(ready, _, _) = select.select([self.input] + [i.input for i in self.build_pipes.values()], [] , [], 1)