diff options
Diffstat (limited to 'bitbake/lib/bb/daemonize.py')
-rw-r--r-- | bitbake/lib/bb/daemonize.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bitbake/lib/bb/daemonize.py b/bitbake/lib/bb/daemonize.py index bf16793468..613fb35536 100644 --- a/bitbake/lib/bb/daemonize.py +++ b/bitbake/lib/bb/daemonize.py | |||
@@ -16,6 +16,10 @@ def createDaemon(function, logfile): | |||
16 | background as a daemon, returning control to the caller. | 16 | background as a daemon, returning control to the caller. |
17 | """ | 17 | """ |
18 | 18 | ||
19 | # Ensure stdout/stderror are flushed before forking to avoid duplicate output | ||
20 | sys.stdout.flush() | ||
21 | sys.stderr.flush() | ||
22 | |||
19 | try: | 23 | try: |
20 | # Fork a child process so the parent can exit. This returns control to | 24 | # Fork a child process so the parent can exit. This returns control to |
21 | # the command-line or shell. It also guarantees that the child will not | 25 | # the command-line or shell. It also guarantees that the child will not |
@@ -66,12 +70,14 @@ def createDaemon(function, logfile): | |||
66 | 70 | ||
67 | try: | 71 | try: |
68 | so = open(logfile, 'a+') | 72 | so = open(logfile, 'a+') |
69 | se = so | ||
70 | os.dup2(so.fileno(), sys.stdout.fileno()) | 73 | os.dup2(so.fileno(), sys.stdout.fileno()) |
71 | os.dup2(se.fileno(), sys.stderr.fileno()) | 74 | os.dup2(so.fileno(), sys.stderr.fileno()) |
72 | except io.UnsupportedOperation: | 75 | except io.UnsupportedOperation: |
73 | sys.stdout = open(logfile, 'a+') | 76 | sys.stdout = open(logfile, 'a+') |
74 | sys.stderr = sys.stdout | 77 | |
78 | # Have stdout and stderr be the same so log output matches chronologically | ||
79 | # and there aren't two seperate buffers | ||
80 | sys.stderr = sys.stdout | ||
75 | 81 | ||
76 | try: | 82 | try: |
77 | function() | 83 | function() |