* [PATCH] bitbake-worker: Gracefully handle SIGTERM
@ 2014-03-09 16:59 Richard Purdie
0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2014-03-09 16:59 UTC (permalink / raw)
To: bitbake-devel
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>
---
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index bc13b4f..c173dbe 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)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-03-09 16:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-09 16:59 [PATCH] bitbake-worker: Gracefully handle SIGTERM Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.