Skip to content

Commit 0c3b977

Browse files
committed
Add comment and check lastOpenFailed first
1 parent d94674c commit 0c3b977

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_file.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ void RawWrite(const char *buffer) {
3636

3737
void ReportFile::ReopenIfNecessary() {
3838
mu->CheckLocked();
39-
if (!lastOpenFailed)
40-
if (fd == kStdoutFd || fd == kStderrFd)
41-
return;
42-
4339
uptr pid = internal_getpid();
4440
if (lastOpenFailed && fd_pid != pid) {
41+
// If lastOpenFailed is set then we fellback to stderr. If this is a new
42+
// process, mark fd as invalid so we attempt to open again.
43+
CHECK_EQ(fd, kStderrFd);
4544
fd = kInvalidFd;
4645
lastOpenFailed = false;
4746
}
47+
if (fd == kStdoutFd || fd == kStderrFd)
48+
return;
4849

4950
// If in tracer, use the parent's file.
5051
if (pid == stoptheworld_tracer_pid)

0 commit comments

Comments
 (0)