summaryrefslogtreecommitdiffstats
path: root/bin/bitbake-worker
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-09 09:59:19 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-09 18:58:49 -0700
commit551406f3f9ee94de09d2da6e16fea054c6dbfdb7 (patch)
treed5d1c30436025a11a30ee9f0d5868c5b9874ec83 /bin/bitbake-worker
parente1d89166f2dfe46412ff9a5610dd57b0cef74fe3 (diff)
downloadbitbake-contrib-551406f3f9ee94de09d2da6e16fea054c6dbfdb7.tar.gz
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin/bitbake-worker')
-rwxr-xr-xbin/bitbake-worker8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker
index bc13b4f31..c173dbe01 100755
--- a/bin/bitbake-worker
+++ b/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)