From 8348557893e91046f2466113d17bc4ac42a04584 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 19 Jan 2024 14:02:48 +0100 Subject: [PATCH] Move crash handling out of crash handler installation --- components/crashcatcher/crashcatcher.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index 044431eca0..f478e2dff8 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -415,11 +415,8 @@ static void getExecPath(char** argv) } } -int crashCatcherInstallHandlers(int argc, char** argv, const char* logfile) +static int crashCatcherInstallHandlers(char** argv) { - if (argc == 2 && strcmp(argv[1], crash_switch) == 0) - crash_handler(logfile); - getExecPath(argv); /* Set an alternate signal stack so SIGSEGVs caused by stack overflows @@ -509,10 +506,11 @@ void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& cra { if ((argc == 2 && strcmp(argv[1], crash_switch) == 0) || !is_debugger_present()) { - if (crashCatcherInstallHandlers(argc, argv, crashLogPath.c_str()) == -1) - { + if (argc == 2 && strcmp(argv[1], crash_switch) == 0) + crash_handler(crashLogPath.c_str()); + + if (crashCatcherInstallHandlers(argv) == -1) Log(Debug::Warning) << "Installing crash handler failed"; - } else Log(Debug::Info) << "Crash handler installed"; }