diff options
| author | Dan Gohman <gohman@apple.com> | 2009-08-13 23:18:56 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-08-13 23:18:56 +0000 |
| commit | 4af229e0ebb2c024835065c113cb52fb17c2eeef (patch) | |
| tree | b224443e5d434c3a669cc8e2afef1ab4d1d7f0cf /llvm/lib/Support | |
| parent | d57cbfc7d80f3d29b632aff405286b8867371674 (diff) | |
| download | bcm5719-llvm-4af229e0ebb2c024835065c113cb52fb17c2eeef.tar.gz bcm5719-llvm-4af229e0ebb2c024835065c113cb52fb17c2eeef.zip | |
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.
llvm-svn: 78953
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index f0090d8d93f..dcd33673acd 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -315,6 +315,10 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary, bool Force, 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_ostream &raw_fd_ostream::resetColor() { // 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) {} |

