handle SIGFPE, SIGQUIT and SIGTERM as well as SIGSEGV

This commit is contained in:
Maxime Coste 2013-02-26 14:13:37 +01:00
parent 6d4552e7d8
commit 2726d11108

View File

@ -799,10 +799,18 @@ RemoteClient* connect_to(const String& pid, const String& init_command)
return remote_client; return remote_client;
} }
void sigsegv_handler(int) void signal_handler(int signal)
{ {
endwin(); 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(); abort();
} }
@ -811,7 +819,12 @@ int main(int argc, char* argv[])
try try
{ {
std::locale::global(std::locale("en_US.UTF-8")); 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<String> params; std::vector<String> params;
for (size_t i = 1; i < argc; ++i) for (size_t i = 1; i < argc; ++i)
params.push_back(argv[i]); params.push_back(argv[i]);