Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH] cooker: Handle SIGTERM more gracefully
@ 2014-03-09 17:05 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2014-03-09 17:05 UTC (permalink / raw)
  To: bitbake-devel

If the cooker receives a SIGTERM it currently hangs using 100% CPU,

This patch adds in an intercept for the event and puts the cooker into
shutdown mode allowing it to exit cleanly/safely and avoiding the hang.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 8d63195..9cb74d1 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -37,6 +37,7 @@ from collections import defaultdict
 import bb, bb.exceptions, bb.command
 from bb import utils, data, parse, event, cache, providers, taskdata, runqueue
 import Queue
+import signal
 import prserv.serv
 
 logger      = logging.getLogger("BitBake")
@@ -149,6 +150,12 @@ class BBCooker:
 
         self.parser = None
 
+        signal.signal(signal.SIGTERM, self.sigterm_exception)
+
+    def sigterm_exception(self, signum, stackframe):
+        bb.warn("Cooker recieved SIGTERM, shutting down...")
+        self.state = state.forceshutdown
+
     def setFeatures(self, features):
         original_featureset = list(self.featureset)
         for feature in features:




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-09 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-09 17:05 [PATCH] cooker: Handle SIGTERM more gracefully Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox