[llvm-commits] [llvm] r78953 - /llvm/trunk/lib/Support/raw_ostream.cpp
Dan Gohman
gohman at apple.com
Thu Aug 13 16:18:56 PDT 2009
Author: djg
Date: Thu Aug 13 18:18:56 2009
New Revision: 78953
URL: http://llvm.org/viewvc/llvm-project?rev=78953&view=rev
Log:
When standard output is a terminal, set outs() to be unbuffered, to
mimic the behavior of stdtout, which is line-buffered when the output
is a terminal. This fixes some issues with bugpoint output appearing
being printed out of order.
Modified:
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=78953&r1=78952&r2=78953&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Aug 13 18:18:56 2009
@@ -315,6 +315,10 @@
if (Binary)
sys::Program::ChangeStdoutToBinary();
ShouldClose = false;
+ // Mimic stdout by defaulting to unbuffered if the output device
+ // is a terminal.
+ if (sys::Process::StandardOutIsDisplayed())
+ SetUnbuffered();
return;
}
@@ -411,7 +415,13 @@
// raw_stdout/err_ostream
//===----------------------------------------------------------------------===//
-raw_stdout_ostream::raw_stdout_ostream():raw_fd_ostream(STDOUT_FILENO, false) {}
+// Set buffer settings to model stdout and stderr behavior.
+// raw_ostream doesn't support line buffering, so set standard output to be
+// unbuffered when the output device is a terminal. Set standard error to
+// be unbuffered.
+raw_stdout_ostream::raw_stdout_ostream()
+ : raw_fd_ostream(STDOUT_FILENO, false,
+ sys::Process::StandardOutIsDisplayed()) {}
raw_stderr_ostream::raw_stderr_ostream():raw_fd_ostream(STDERR_FILENO, false,
true) {}
More information about the llvm-commits
mailing list