Index: lib/Support/raw_ostream.cpp =================================================================== --- lib/Support/raw_ostream.cpp +++ lib/Support/raw_ostream.cpp @@ -473,7 +473,7 @@ // possible. if (!(Flags & sys::fs::F_Text)) sys::ChangeStdoutToBinary(); - return dup(STDOUT_FILENO); + return STDOUT_FILENO; } int FD; @@ -497,6 +497,8 @@ ShouldClose = false; return; } + if (FD <= STDERR_FILENO) + ShouldClose = false; // Get the starting position. off_t loc = ::lseek(FD, 0, SEEK_CUR);