aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-12-16 08:38:57 -0700
committerChris Larson <chris_larson@mentor.com>2010-12-16 10:42:51 -0700
commit3f851320391f2b14206c8f5112f270176c51a089 (patch)
tree7176df71bfef0c5c1076394587a96777ba6fc25d /bin
parent20eb69cfc69a9af00cc65e7e90c295e46f74a0d4 (diff)
downloadbitbake-3f851320391f2b14206c8f5112f270176c51a089.tar.gz
Forcibly shut down the server if the UI is terminated
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bitbake26
1 files changed, 16 insertions, 10 deletions
diff --git a/bin/bitbake b/bin/bitbake
index 2cf131db8..fcf8ca56c 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -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