]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
Forcibly shut down the server if the UI is terminated
authorChris Larson <chris_larson@mentor.com>
Thu, 16 Dec 2010 15:38:57 +0000 (08:38 -0700)
committerChris Larson <chris_larson@mentor.com>
Thu, 16 Dec 2010 17:42:51 +0000 (10:42 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
bin/bitbake
lib/bb/server/process.py

index 2cf131db8ab430127aafaf0f6b472e07c26641f5..fcf8ca56ca2dc87a835c4efd1bdb48caa70cfea1 100755 (executable)
@@ -189,20 +189,26 @@ Default BBFILES are the .bb files in the current directory.""")
     server = ProcessServer(server_channel, event_queue, configuration)
     server.start()
 
-    try:
-        return ui_main(ServerCommunicator(ui_channel), event_queue)
-    finally:
-        # the server is stopping, so don't let the user do crazy things with
-        # extra Ctrl-C invocations.  If the server does hang, however, the user
-        # won't be able to kill us.
-        #
-        # @todo come up with better mechanism - may need to catch KeyboardInterrupt
-        # here and do a server.terminate()
+    def shutdown(force=False):
         signal.signal(signal.SIGINT, signal.SIG_IGN)
         server.stop()
-        server.join()
+        if force:
+            server.join(0.5)
+            if server.is_alive():
+                server.terminate()
+                server.join()
+        else:
+            server.join()
         ui_channel.close()
         event_queue.close()
+        if force:
+            sys.exit(1)
+
+    signal.signal(signal.SIGTERM, lambda i, s: shutdown(force=True))
+    try:
+        return ui_main(ServerCommunicator(ui_channel), event_queue)
+    finally:
+        shutdown()
 
     return 1
 
index 77ef6adb5bd1f376a532a358ffe907b8ce047bb3..c3aaa7fb9d4cdd4b008a52482ee689734a5f02f1 100644 (file)
@@ -108,7 +108,7 @@ class ProcessServer(Process):
                     self.runCommand(command)
 
                 self.idle_commands(.1)
-            except Exception, exc:
+            except Exception:
                 logger.exception('Running command %s', command)
 
         self.event_queue.cancel_join_thread()