[bitbake-devel,1/3] server/process/daemonize: Use sys.exit(), not os._exit() for server

Submitted by Richard Purdie on Aug. 22, 2020, 2:16 p.m. | Patch ID: 175551


Message ID 20200822141658.1312549-1-richard.purdie@linuxfoundation.org
State Master Next
Commit 49abfc650fdfe481ec338f7ed8176deab57c1a1b
Headers show

Commit Message

Richard Purdie Aug. 22, 2020, 2:16 p.m.
By using os._exit() in the server, we confuse python programmers no end
since atexit calls, along with threading cleanup calls are skipped. We're
careful about the environment the server is created within so we should
be able to use sys.exit() here and have things behave as the python devs

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
 lib/bb/daemonize.py      | 4 +---
 lib/bb/server/process.py | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/daemonize.py b/lib/bb/daemonize.py
index f01e6ec7cc..0ec5ef3986 100644
--- a/lib/bb/daemonize.py
+++ b/lib/bb/daemonize.py
@@ -89,9 +89,7 @@  def createDaemon(function, logfile):
-        # os._exit() doesn't flush open files like os.exit() does. Manually flush
-        # stdout and stderr so that any logging output will be seen, particularly
+        # Manually flush stdout and stderr so that any logging output will be seen, particularly
         # exception tracebacks.
-        os._exit(0)
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 65e1eab527..b03d64391b 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -492,6 +492,7 @@  class BitBakeServer(object):
             # Flush any ,essages/errors to the logfile before exit
+        sys.exit(0)
 def connectProcessServer(sockname, featureset):
     # Connect to socket