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");