Abort process when abnormal shutdown is initiated to allow coredumps to be generated

This commit is contained in:
Johannes M. Scheuermann 2024-02-09 10:47:08 +01:00
parent 09b593c328
commit 4f0361419b
1 changed files with 7 additions and 0 deletions

View File

@ -3414,6 +3414,13 @@ extern "C" void flushAndExit(int exitCode) {
// to the crashAndDie call below.
TerminateProcess(GetCurrentProcess(), exitCode);
#else
// Send a signal to allow the Kernel to generate a coredump for this process.
// See: https://man7.org/linux/man-pages/man5/core.5.html
// The abort method will send a SIGABRT, which causes the kernel to collect a coredump.
// See: https://pubs.opengroup.org/onlinepubs/9699919799/functions/abort.html.
if (exitCode != FDB_EXIT_SUCCESS)
abort();
// In the success case exit the process gracefully.
_exit(exitCode);
#endif
// should never reach here, but you never know