<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 7, 2015 at 8:55 AM, Richard Purdie <span dir="ltr">&lt;<a href="mailto:richard.purdie@linuxfoundation.org" target="_blank">richard.purdie@linuxfoundation.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":10q" class="" style="overflow:hidden">Currently if you send a SIGTERM to the <span class="">bitbake</span> UI process, the system basically<br>
hangs if tasks are executing. This is because the server process doesn&#39;t<br>
actually try any kind of shutdown before exiting.<br>
<br>
This patch trys executing a stateForceShutdown command first, which is<br>
enough to stop any active tasks before the system exits.<br>
<br>
I also noticed that terminate can execute multiple times, once at SIGTERM<br>
from the handler and once from the real exit. Double execution leads to<br>
stack traces and potential hangs (writes to dead pipes), so ensure<br>
the code only can run once.<br>
<br>
With these fixes, <span class="">bitbake</span> much more correctly deals with SIGTERM to the<br>
UI process.<br>
<br>
Signed-off-by: Richard Purdie &lt;<a href="mailto:richard.purdie@linuxfoundation.org">richard.purdie@linuxfoundation.org</a>&gt;</div></blockquote></div><br>Just as an FYI for consideration in the longer term, you can raise an exception from a signal handler, to handle sigterm the same way as sigint for consistency. Ex.:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="https://github.com/kergoth/oe-test-scripts/blob/master/bb_test.py#L12-L17">https://github.com/kergoth/oe-test-scripts/blob/master/bb_test.py#L12-L17</a> + <a href="https://github.com/kergoth/oe-test-scripts/blob/master/bb_test.py#L171-L180">https://github.com/kergoth/oe-test-scripts/blob/master/bb_test.py#L171-L180</a></div><div class="gmail_extra"><br></div><div class="gmail_extra">Which reminds me, we don&#39;t exit with the correct exit code for sigint/sigterm, so the calling shell doesn&#39;t know the cause of the exit. See also <a href="http://www.cons.org/cracauer/sigint.html">http://www.cons.org/cracauer/sigint.html</a> -- fantastic article there, highly recommended.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="https://docs.python.org/3/library/signal.html#example">https://docs.python.org/3/library/signal.html#example</a> has an example of raising an exception from another signal handler, so it seems to be kosher.<br></div><div class="gmail_extra">-- <br><div class="gmail_signature">Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>