diff options
-rwxr-xr-x | bin/bitbake | 26 | ||||
-rw-r--r-- | lib/bb/server/process.py | 2 |
2 files changed, 17 insertions, 11 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 diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py index 77ef6adb5..c3aaa7fb9 100644 --- a/lib/bb/server/process.py +++ b/lib/bb/server/process.py @@ -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() |