From 2726d1110858ae2cb5c5fbb448c25a7ef6181cba Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 26 Feb 2013 14:13:37 +0100 Subject: [PATCH] handle SIGFPE, SIGQUIT and SIGTERM as well as SIGSEGV --- src/main.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index e388724c..0867abea 100644 --- a/src/main.cc +++ b/src/main.cc @@ -799,10 +799,18 @@ RemoteClient* connect_to(const String& pid, const String& init_command) return remote_client; } -void sigsegv_handler(int) +void signal_handler(int signal) { endwin(); - on_assert_failed("Kakoune SEGFAULT !"); + const char* text = nullptr; + switch (signal) + { + case SIGSEGV: text = "SIGSEGV"; break; + case SIGFPE: text = "SIGFPE"; break; + case SIGQUIT: text = "SIGQUIT"; break; + case SIGTERM: text = "SIGTERM"; break; + } + on_assert_failed(text); abort(); } @@ -811,7 +819,12 @@ int main(int argc, char* argv[]) try { std::locale::global(std::locale("en_US.UTF-8")); - signal(SIGSEGV, sigsegv_handler); + + signal(SIGSEGV, signal_handler); + signal(SIGFPE, signal_handler); + signal(SIGQUIT, signal_handler); + signal(SIGTERM, signal_handler); + std::vector params; for (size_t i = 1; i < argc; ++i) params.push_back(argv[i]);