Don't clobber game log file when we collect a stack trace.

When the crash catcher catch a signal it forks to collect data about its
parent. In the process the child reinitialize the log file, which ends
up empty.
This commit is contained in:
fredzio 2021-04-17 09:12:03 +02:00
parent 0b8cae4af8
commit 4058e117ca
3 changed files with 9 additions and 2 deletions

View file

@ -179,7 +179,12 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
std::cerr.rdbuf (&sb);
#else
// Redirect cout and cerr to the log file
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName));
// If we are collecting a stack trace, append to existing log file
std::ios_base::openmode mode = std::ios::out;
if(argc == 2 && strcmp(argv[1], crash_switch) == 0)
mode |= std::ios::app;
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName), mode);
coutsb.open (Debug::Tee(logfile, oldcout));
cerrsb.open (Debug::Tee(logfile, oldcerr));