mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-29 03:19:44 +00:00
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:
parent
0b8cae4af8
commit
4058e117ca
@ -43,7 +43,7 @@ namespace bfs = boost::filesystem;
|
||||
#include <sys/user.h>
|
||||
#endif
|
||||
|
||||
static const char crash_switch[] = "--cc-handle-crash";
|
||||
#include "crashcatcher.hpp"
|
||||
|
||||
static const char fatal_err[] = "\n\n*** Fatal Error ***\n";
|
||||
static const char pipe_err[] = "!!! Failed to create pipe\n";
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define USE_CRASH_CATCHER 0
|
||||
#endif
|
||||
|
||||
constexpr char crash_switch[] = "--cc-handle-crash";
|
||||
|
||||
#if USE_CRASH_CATCHER
|
||||
extern void crashCatcherInstall(int argc, char **argv, const std::string &crashLogPath);
|
||||
#else
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user