summaryrefslogtreecommitdiffstats
path: root/lib/bb/server/process.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-07 15:48:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-08 23:45:03 +0100
commit1032ddddbe3241da02ebb3608a1c40f9123b9e80 (patch)
tree53e8e46e53e19f7e63f4ec4710d39fe37270cc22 /lib/bb/server/process.py
parenta841dc85770ea5c6fa8cf06ba5fdfe214e69afb2 (diff)
downloadbitbake-contrib-1032ddddbe3241da02ebb3608a1c40f9123b9e80.tar.gz
server/process: Handle SIGTERM more gracefully
Currently if you send a SIGTERM to the bitbake UI process, the system basically hangs if tasks are executing. This is because the server process doesn't actually try any kind of shutdown before exiting. This patch trys executing a stateForceShutdown command first, which is enough to stop any active tasks before the system exits. I also noticed that terminate can execute multiple times, once at SIGTERM from the handler and once from the real exit. Double execution leads to stack traces and potential hangs (writes to dead pipes), so ensure the code only can run once. With these fixes, bitbake much more correctly deals with SIGTERM to the UI process. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/server/process.py')
-rw-r--r--lib/bb/server/process.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index f022b86c9..5fca3508b 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -114,6 +114,10 @@ class ProcessServer(Process, BaseImplServer):
if self.quitout.poll():
self.quitout.recv()
self.quit = True
+ try:
+ self.runCommand(["stateForceShutdown"])
+ except:
+ pass
self.idle_commands(.1, [self.command_channel, self.quitout])
except Exception:
@@ -123,6 +127,7 @@ class ProcessServer(Process, BaseImplServer):
bb.event.unregister_UIHhandler(self.event_handle.value)
self.command_channel.close()
self.cooker.shutdown(True)
+ self.quitout.close()
def idle_commands(self, delay, fds=None):
nextsleep = delay
@@ -172,12 +177,16 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
self.event_queue = event_queue
self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle, self.procserver)
self.events = self.event_queue
+ self.terminated = False
def sigterm_terminate(self):
bb.error("UI received SIGTERM")
self.terminate()
def terminate(self):
+ if self.terminated:
+ return
+ self.terminated = True
def flushevents():
while True:
try: