diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-09 09:59:19 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-10 11:09:58 -0700 |
commit | 15688798520896690561824b2fdc227c8a365c82 (patch) | |
tree | f8532a89cf9f9a6b287ecb43c0ac5711379e486d /bitbake/bin | |
parent | a7bc031f847c45b2d266cfbf8e203155ab0166b9 (diff) | |
download | poky-15688798520896690561824b2fdc227c8a365c82.tar.gz |
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 <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake-worker | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index bc13b4f314..c173dbe01d 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
@@ -242,6 +242,14 @@ class BitbakeWorker(object): | |||
242 | self.build_pids = {} | 242 | self.build_pids = {} |
243 | self.build_pipes = {} | 243 | self.build_pipes = {} |
244 | 244 | ||
245 | signal.signal(signal.SIGTERM, self.sigterm_exception) | ||
246 | |||
247 | def sigterm_exception(self, signum, stackframe): | ||
248 | bb.warn("Worker recieved SIGTERM, shutting down...") | ||
249 | self.handle_finishnow(None) | ||
250 | signal.signal(signal.SIGTERM, signal.SIG_DFL) | ||
251 | os.kill(os.getpid(), signal.SIGTERM) | ||
252 | |||
245 | def serve(self): | 253 | def serve(self): |
246 | while True: | 254 | while True: |
247 | (ready, _, _) = select.select([self.input] + [i.input for i in self.build_pipes.values()], [] , [], 1) | 255 | (ready, _, _) = select.select([self.input] + [i.input for i in self.build_pipes.values()], [] , [], 1) |