FatalSignalHandler: simplify SA_RESETHAND code

And remove the unreachable code after std::abort() that was meant to
mimic that in INTEGRITY. The next commit will fix this properly.

Pick-to: 6.3
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb772018add694
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-02 19:23:38 -07:00
parent 3e596da488
commit c4600b2e25

View File

@ -88,6 +88,9 @@
# if !defined(Q_OS_INTEGRITY)
# include <sys/resource.h>
# endif
# ifndef SA_RESETHAND
# define SA_RESETHAND 0
# endif
#endif
#if defined(Q_OS_MACOS)
@ -1843,6 +1846,9 @@ public:
struct sigaction act;
memset(&act, 0, sizeof(act));
// Remove the handler after it is invoked.
act.sa_flags = SA_RESETHAND;
# ifdef SA_SIGINFO
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = FatalSignalHandler::actionHandler;
@ -1850,11 +1856,6 @@ public:
act.sa_handler = FatalSignalHandler::regularHandler;
# endif
// Remove the handler after it is invoked.
# if !defined(Q_OS_INTEGRITY)
act.sa_flags = SA_RESETHAND;
# endif
// tvOS/watchOS both define SA_ONSTACK (in sys/signal.h) but mark sigaltstack() as
// unavailable (__WATCHOS_PROHIBITED __TVOS_PROHIBITED in signal.h)
# if defined(SA_ONSTACK) && !defined(Q_OS_TVOS) && !defined(Q_OS_WATCHOS)
@ -1954,14 +1955,6 @@ private:
"\n Function time: ", asyncSafeToString(msecsFunctionTime),
"ms Total time: ", asyncSafeToString(msecsTotalTime), "ms\n");
std::abort();
# if defined(Q_OS_INTEGRITY)
{
struct sigaction act;
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_DFL;
sigaction(signum, &act, NULL);
}
# endif
}
[[maybe_unused]] static void regularHandler(int signum)