Skip to content

Commit cceedbc

Browse files
Don't close old debug log file handle prematurely when trying to re-open (on SIGHUP)
1 parent 2ddce35 commit cceedbc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/logging.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ void BCLog::Logger::LogPrintStr(const std::string &str)
219219
// reopen the log file, if requested
220220
if (m_reopen_file) {
221221
m_reopen_file = false;
222-
m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout);
223-
if (!m_fileout) {
224-
return;
222+
FILE* new_fileout = fsbridge::fopen(m_file_path, "a");
223+
if (new_fileout) {
224+
setbuf(new_fileout, nullptr); // unbuffered
225+
fclose(m_fileout);
226+
m_fileout = new_fileout;
225227
}
226-
setbuf(m_fileout, nullptr); // unbuffered
227228
}
228-
229229
FileWriteStr(strTimestamped, m_fileout);
230230
}
231231
}

0 commit comments

Comments
 (0)