summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2012-09-17 17:43:31 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-09-24 15:35:13 +0100
commitc6a367bc3224adafca698a4ffc5414ad83842c16 (patch)
tree775794972de538116b2ffd5843131ada4fcd32f1
parentcffe80d82a46aaf52ff4a7b6409435754043553f (diff)
downloadbitbake-c6a367bc3224adafca698a4ffc5414ad83842c16.tar.gz
bitbake: Unbuffer stdout for log files
It is possible to lose critical log data when python exits in an unorderly fashion via segmentation fault or certain types of crashes. This is because the buffer characteristics are inherited from the top level stdout, which should be set to unbuffered, for the purpose of all the forked children. This pushes the buffering to the OS, instead of having python managing the buffers in its stream handler class. This change is also to provide the ability to tail logs written from processes in "real time" because they would be written in an orderly fashion depending upon the OS characteristics for the file I/O. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbin/bitbake8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/bitbake b/bin/bitbake
index 8c4602425..37c10451d 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -43,6 +43,14 @@ from bb import server
__version__ = "1.15.3"
logger = logging.getLogger("BitBake")
+# Unbuffer stdout to avoid log truncation in the event
+# of an unorderly exit as well as to provide timely
+# updates to log files for use with tail
+try:
+ if sys.stdout.name == '<stdout>':
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+except:
+ pass
class BBConfiguration(object):
"""