]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
cooker: Handle SIGTERM more gracefully
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 9 Mar 2014 17:05:54 +0000 (10:05 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 10 Mar 2014 01:58:49 +0000 (18:58 -0700)
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>
lib/bb/cooker.py

index 8d63195189a86fffb7295687a293608903107524..9cb74d1818bb91409c5d02e66abb920e7c3f6362 100644 (file)
@@ -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: