mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
Make raw_fd_ostream consider itself the owner of STDOUT_FILENO when
constructed with an output filename of "-". In particular, allow the file descriptor to be closed, and close the file descriptor in the destructor if it hasn't been explicitly closed already, to ensure that any write errors are detected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111436 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
4bb4641784
commit
2499990699
2 files changed
+10
-4
No files matched your search
@@ -377,14 +377,17 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
||||
|
||||
ErrorInfo.clear();
|
||||
|
||||
// Handle "-" as stdout.
|
||||
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
||||
// the owner of stdout. This means that we can do things like close the
|
||||
// file descriptor when we're done and set the "binary" flag globally.
|
||||
if (Filename[0] == '-' && Filename[1] == 0) {
|
||||
FD = STDOUT_FILENO;
|
||||
// If user requested binary then put stdout into binary mode if
|
||||
// possible.
|
||||
if (Flags & F_Binary)
|
||||
sys::Program::ChangeStdoutToBinary();
|
||||
ShouldClose = false;
|
||||
// Close stdout when we're done, to detect any output errors.
|
||||
ShouldClose = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user