Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#531 : reuse old style signal handler #532

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading