]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: daemonize: Ensure child process exits safely
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 31 Jul 2017 10:30:56 +0000 (11:30 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 31 Jul 2017 14:13:53 +0000 (15:13 +0100)
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.

(Bitbake rev: dec1d2c26f6cb3ffeb44beaab0129cd531a6d08b)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/daemonize.py

index 8380828a170e693e0c8ec1f25e644909ec41bbc6..a4664ad76b6b0c52ee7cce67f6ba4b55b70607fe 100644 (file)
@@ -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)