use default signal handler after cleanup

With the current setup, on Linux, SIGILL (and SIGSEGV/SIGBUS etc., in the case
of a program bug) lead to no feedback if they occur after the signal handlers
are installed, they just exit silently. By invoking the default signal handler,
we can still get the appropriate feedback. This is particularly important for
feedback if someone downloads the wrong SF binary and runs it on Linux.

closes https://github.com/official-stockfish/Stockfish/pull/6554

No functional change
This commit is contained in:
anematode
2026-01-18 08:53:06 +01:00
committed by Joost VandeVondele
parent 71f53b92c7
commit f61d4317a3
+10 -1
View File
@@ -106,7 +106,16 @@ class CleanupHooks {
// Search threads may still be running, so skip munmap (but still perform
// other cleanup actions). The memory mappings will be released on exit.
SharedMemoryRegistry::cleanup_all(true);
_Exit(128 + sig);
// Invoke the default handler, which will exit
struct sigaction sa;
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction(sig, &sa, nullptr) == -1)
_Exit(128 + sig);
raise(sig);
}
static void register_signal_handlers() noexcept {