[PATCH] D114897: [flang] Don't close stderr in runtime (fixes STOP output)
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 1 13:25:33 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f6dbf1a75b2: [flang] Don't close stderr in runtime (fixes STOP output) (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114897/new/
https://reviews.llvm.org/D114897
Files:
flang/runtime/file.cpp
flang/runtime/file.h
Index: flang/runtime/file.h
===================================================================
--- flang/runtime/file.h
+++ flang/runtime/file.h
@@ -85,6 +85,7 @@
position_ = pos;
openPosition_.reset();
}
+ void CloseFd(IoErrorHandler &);
int fd_{-1};
OwningPtr<char> path_;
Index: flang/runtime/file.cpp
===================================================================
--- flang/runtime/file.cpp
+++ flang/runtime/file.cpp
@@ -66,16 +66,7 @@
(status == OpenStatus::Old || status == OpenStatus::Unknown)) {
return;
}
- if (fd_ >= 0) {
- if (fd_ <= 2) {
- // don't actually close a standard file descriptor, we might need it
- } else {
- if (::close(fd_) != 0) {
- handler.SignalErrno();
- }
- }
- fd_ = -1;
- }
+ CloseFd(handler);
if (status == OpenStatus::Scratch) {
if (path_.get()) {
handler.SignalError("FILE= must not appear with STATUS='SCRATCH'");
@@ -179,12 +170,7 @@
break;
}
path_.reset();
- if (fd_ >= 0) {
- if (::close(fd_) != 0) {
- handler.SignalErrno();
- }
- fd_ = -1;
- }
+ CloseFd(handler);
}
std::size_t OpenFile::Read(FileOffset at, char *buffer, std::size_t minBytes,
@@ -410,6 +396,19 @@
return id;
}
+void OpenFile::CloseFd(IoErrorHandler &handler) {
+ if (fd_ >= 0) {
+ if (fd_ <= 2) {
+ // don't actually close a standard file descriptor, we might need it
+ } else {
+ if (::close(fd_) != 0) {
+ handler.SignalErrno();
+ }
+ }
+ fd_ = -1;
+ }
+}
+
bool IsATerminal(int fd) { return ::isatty(fd); }
#ifdef WIN32
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114897.391126.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/87ebeb15/attachment.bin>
More information about the llvm-commits
mailing list