From e954d49c290689d3f2f83855ddff03bc18b1259d Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 8 Jun 2024 00:57:56 +0200 Subject: [PATCH] feat: Handle SIGINT --- main/gui/source/crash_handlers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index 59987984d..574b50073 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -120,6 +120,11 @@ namespace hex::crash { // Custom signal handler to print various information and a stacktrace when the application crashes static void signalHandler(int signalNumber, const std::string &signalName) { + if (signalNumber == SIGINT) { + ImHexApi::System::closeImHex(); + return; + } + // Reset crash handlers, so we can't have a recursion if this code crashes resetCrashHandlers(); @@ -166,6 +171,7 @@ namespace hex::crash { HANDLE_SIGNAL(SIGILL); HANDLE_SIGNAL(SIGABRT); HANDLE_SIGNAL(SIGFPE); + HANDLE_SIGNAL(SIGINT); #if defined (SIGBUS) HANDLE_SIGNAL(SIGBUS);