g3log catches fatal events (like SIGSEGV or SIGILL), generates a stack dump, flushes all log entries to the sinks, and then re-emits the signal.
Customizing Fatal Signals (Linux/Unix)
By default, g3log handles SIGABRT, SIGFPE, SIGILL, SIGSEGV, and SIGTERM. You can override this list using g3::overrideSetupSignals to add or remove signals (for example, if SIGTERM is used by another library like ZMQ and should be skipped).
Pre-fatal Hook
You can define a callback function that executes immediately before the fatal signal handling occurs. This is useful for performing critical cleanup tasks during a crash.
Disabling Fatal Handling
Fatal signal handling can be disabled entirely at build time using the CMake option ENABLE_FATAL_SIGNALHANDLING.
// Example when SIGTERM is skipped due to ZMQ usage
g3::overrideSetupSignals({ {SIGABRT, "SIGABRT"},
{SIGFPE, "SIGFPE"},
{SIGILL, "SIGILL"},
{SIGSEGV, "SIGSEGV"}});
// Example of how to enforce important shutdown cleanup even in the event of a fatal crash:
g3::setFatalPreLoggingHook([]{ cleanup(); });