diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-31 11:30:56 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-31 12:03:04 +0100 |
commit | dec1d2c26f6cb3ffeb44beaab0129cd531a6d08b (patch) | |
tree | b3ecbb955c1d6ae74c03b808594db7ed604a26b9 | |
parent | 10a6a48c0c5a2fe2051e90143e66075356853971 (diff) | |
download | bitbake-contrib-dec1d2c26f6cb3ffeb44beaab0129cd531a6d08b.tar.gz |
daemonize: Ensure child process exits safely
When we create the child, if an exception occurred it was transfering
back into the parent context. We don't want to do that us use a try/finally
to ensure we exit.
We need to ensure a traceback is printed and any queued UI messages which
may not have made it to the client UI at this point.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/daemonize.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/bb/daemonize.py b/lib/bb/daemonize.py index 8380828a1..a4664ad76 100644 --- a/lib/bb/daemonize.py +++ b/lib/bb/daemonize.py @@ -30,6 +30,7 @@ __version__ = "0.2" import os # Miscellaneous OS interfaces. import sys # System-specific parameters and functions. import io +import traceback # Default daemon parameters. # File mode creation mask of the daemon. @@ -192,6 +193,10 @@ def createDaemon(function, logfile): sys.stdout = open(logfile, 'a+') sys.stderr = sys.stdout - function() - - os._exit(0) + try: + function() + except Exception as e: + traceback.print_exc() + bb.event.print_ui_queue() + finally: + os._exit(0) |