FatalSignalHandler: simplify the SA_SIGINFO handling

The #if around the function declaration was ugly.

Pick-to: 6.3
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb7540f5da080f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-02 18:50:10 -07:00
parent 65ff731b62
commit 3e596da488

View File

@ -1845,9 +1845,9 @@ public:
memset(&act, 0, sizeof(act));
# ifdef SA_SIGINFO
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = FatalSignalHandler::signal;
act.sa_sigaction = FatalSignalHandler::actionHandler;
# else
act.sa_handler = FatalSignalHandler::signal;
act.sa_handler = FatalSignalHandler::regularHandler;
# endif
// Remove the handler after it is invoked.
@ -1916,9 +1916,9 @@ public:
auto isOurs = [](const struct sigaction &old) {
# ifdef SA_SIGINFO
return (old.sa_flags & SA_SIGINFO) && old.sa_sigaction == FatalSignalHandler::signal;
return (old.sa_flags & SA_SIGINFO) && old.sa_sigaction == FatalSignalHandler::actionHandler;
# else
return old.sa_handler == FatalSignalHandler::signal;
return old.sa_handler == FatalSignalHandler::regularHandler;
# endif
};
struct sigaction action;
@ -1937,11 +1937,7 @@ public:
private:
Q_DISABLE_COPY_MOVE(FatalSignalHandler)
# ifdef SA_SIGINFO
static void signal(int signum, siginfo_t * /* info */, void * /* ucontext */)
# else
static void signal(int signum)
#endif
static void actionHandler(int signum, siginfo_t * /* info */, void * /* ucontext */)
{
const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime());
const int msecsTotalTime = qRound(QTestLog::msecsTotalTime());
@ -1968,6 +1964,11 @@ private:
# endif
}
[[maybe_unused]] static void regularHandler(int signum)
{
actionHandler(signum, nullptr, nullptr);
}
sigset_t handledSignals;
static bool pauseOnCrash;
};