Skip to content

Commit

Permalink
Don't close old debug log file handle prematurely when trying to re-o…
Browse files Browse the repository at this point in the history
…pen (on SIGHUP)
  • Loading branch information
practicalswift committed Aug 29, 2018
1 parent 2ddce35 commit cceedbc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ void BCLog::Logger::LogPrintStr(const std::string &str)
// reopen the log file, if requested
if (m_reopen_file) {
m_reopen_file = false;
m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout);
if (!m_fileout) {
return;
FILE* new_fileout = fsbridge::fopen(m_file_path, "a");
if (new_fileout) {
setbuf(new_fileout, nullptr); // unbuffered
fclose(m_fileout);
m_fileout = new_fileout;
}
setbuf(m_fileout, nullptr); // unbuffered
}

FileWriteStr(strTimestamped, m_fileout);
}
}
Expand Down

0 comments on commit cceedbc

Please sign in to comment.