summaryrefslogtreecommitdiffstats
path: root/bitbake/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-09 14:27:55 +0100
commit384533bdb47af2c3a0f3faea8879e8f3cb6f39f9 (patch)
treeec9edbe679a9b1d6988e9a42e599b3209b5e7414 /bitbake/lib/bb/server/process.py
parentdae69e6dcfa177844bb41a156b1bab091db3f1e7 (diff)
downloadpoky-384533bdb47af2c3a0f3faea8879e8f3cb6f39f9.tar.gz
bitbake: 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. (Bitbake rev: 1032ddddbe3241da02ebb3608a1c40f9123b9e80) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server/process.py')
-rw-r--r--bitbake/lib/bb/server/process.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index f022b86c94..5fca3508b1 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -114,6 +114,10 @@ class ProcessServer(Process, BaseImplServer):
114 if self.quitout.poll(): 114 if self.quitout.poll():
115 self.quitout.recv() 115 self.quitout.recv()
116 self.quit = True 116 self.quit = True
117 try:
118 self.runCommand(["stateForceShutdown"])
119 except:
120 pass
117 121
118 self.idle_commands(.1, [self.command_channel, self.quitout]) 122 self.idle_commands(.1, [self.command_channel, self.quitout])
119 except Exception: 123 except Exception:
@@ -123,6 +127,7 @@ class ProcessServer(Process, BaseImplServer):
123 bb.event.unregister_UIHhandler(self.event_handle.value) 127 bb.event.unregister_UIHhandler(self.event_handle.value)
124 self.command_channel.close() 128 self.command_channel.close()
125 self.cooker.shutdown(True) 129 self.cooker.shutdown(True)
130 self.quitout.close()
126 131
127 def idle_commands(self, delay, fds=None): 132 def idle_commands(self, delay, fds=None):
128 nextsleep = delay 133 nextsleep = delay
@@ -172,12 +177,16 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
172 self.event_queue = event_queue 177 self.event_queue = event_queue
173 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle, self.procserver) 178 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle, self.procserver)
174 self.events = self.event_queue 179 self.events = self.event_queue
180 self.terminated = False
175 181
176 def sigterm_terminate(self): 182 def sigterm_terminate(self):
177 bb.error("UI received SIGTERM") 183 bb.error("UI received SIGTERM")
178 self.terminate() 184 self.terminate()
179 185
180 def terminate(self): 186 def terminate(self):
187 if self.terminated:
188 return
189 self.terminated = True
181 def flushevents(): 190 def flushevents():
182 while True: 191 while True:
183 try: 192 try: