From: Richard Purdie Date: Sun, 9 Mar 2014 16:59:19 +0000 (-0700) Subject: bitbake: bitbake-worker: Gracefully handle SIGTERM X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=15688798520896690561824b2fdc227c8a365c82;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git bitbake: bitbake-worker: Gracefully handle SIGTERM 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. (Bitbake rev: 551406f3f9ee94de09d2da6e16fea054c6dbfdb7) Signed-off-by: Richard Purdie --- diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index bc13b4f3143..c173dbe01d4 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker @@ -242,6 +242,14 @@ class BitbakeWorker(object): 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)