[bitbake-devel] [PATCH] server/process: Handle SIGTERM more gracefully

Christopher Larson clarson at kergoth.com
Mon Sep 7 20:17:25 UTC 2015

On Mon, Sep 7, 2015 at 8:55 AM, Richard Purdie <
richard.purdie at linuxfoundation.org> wrote:

> 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 at linuxfoundation.org>

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.:

https://github.com/kergoth/oe-test-scripts/blob/master/bb_test.py#L12-L17 +

Which reminds me, we don't exit with the correct exit code for
sigint/sigterm, so the calling shell doesn't know the cause of the exit.
See also http://www.cons.org/cracauer/sigint.html -- fantastic article
there, highly recommended.

https://docs.python.org/3/library/signal.html#example has an example of
raising an exception from another signal handler, so it seems to be kosher.
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20150907/e91333be/attachment-0002.html>

More information about the bitbake-devel mailing list