Skip to content

Commit e9a4691

Browse files
author
Dan Gohman
committed
Make outs() close its file when its stream is destructed, so that
pending output errors are detected. llvm-svn: 111643
1 parent 443f2d6 commit e9a4691

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Support/raw_ostream.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,16 @@ bool raw_fd_ostream::is_displayed() const {
540540
}
541541

542542
//===----------------------------------------------------------------------===//
543-
// raw_stdout/err_ostream
543+
// outs(), errs(), nulls()
544544
//===----------------------------------------------------------------------===//
545545

546546
/// outs() - This returns a reference to a raw_ostream for standard output.
547547
/// Use it like: outs() << "foo" << "bar";
548548
raw_ostream &llvm::outs() {
549549
// Set buffer settings to model stdout behavior.
550-
static raw_fd_ostream S(STDOUT_FILENO, false);
550+
// Delete the file descriptor when the program exists, forcing error
551+
// detection. If you don't want this behavior, don't use outs().
552+
static raw_fd_ostream S(STDOUT_FILENO, true);
551553
return S;
552554
}
553555

0 commit comments

Comments
 (0)