From 90b21d8cdbb100024b89617c4e311c19f00e0f7b Mon Sep 17 00:00:00 2001 From: LI Daobing Date: Wed, 13 Mar 2024 22:59:34 -0700 Subject: [PATCH] #531 : reuse old style signal handler --- src/main/iptux.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/iptux.cpp b/src/main/iptux.cpp index 9d6648c8..e7e8deed 100644 --- a/src/main/iptux.cpp +++ b/src/main/iptux.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "iptux/Application.h" @@ -137,8 +138,27 @@ static void dealLog(const IptuxConfig& config) { } } +static void segvHandler(int sig) { + void *array[99]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 99); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + +static void installCrashHandler() { + signal(SIGSEGV, segvHandler); + signal(SIGABRT, segvHandler); + signal(SIGTRAP, segvHandler); +} + int main(int argc, char** argv) { - google::InstallFailureSignalHandler(); + installCrashHandler(); setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, __LOCALE_PATH); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");