Skip to content

Commit

Permalink
Merge pull request #532 from iptux-src/issue_531
Browse files Browse the repository at this point in the history
#531 : reuse old style signal handler
  • Loading branch information
lidaobing authored Mar 14, 2024
2 parents 59cdb2c + 90b21d8 commit 043616b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/iptux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <glib/gi18n.h>
#include <glog/logging.h>
#include <execinfo.h>

#include "iptux/Application.h"

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 043616b

Please sign in to comment.