Unblock faulting thread signal handler after log flush is complete (#419)

This commit is contained in:
Szekely Gyorgy 2021-11-22 16:39:53 +01:00 committed by GitHub
parent 9009e109e9
commit c51128f051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,8 @@
namespace {
std::atomic<bool> gBlockForFatal {true};
const std::map<int, std::string> kSignals = {
{SIGABRT, "SIGABRT"},
{SIGFPE, "SIGFPE"},
@ -134,10 +136,9 @@ namespace g3 {
namespace internal {
bool shouldBlockForFatalHandling() {
return true; // For windows we will after fatal processing change it to false
return gBlockForFatal;
}
/// Generate stackdump. Or in case a stackdump was pre-generated and non-empty just use that one
/// i.e. the latter case is only for Windows and test purposes
std::string stackdump(const char* rawdump) {
@ -230,6 +231,12 @@ namespace g3 {
kill(getpid(), signal_number);
// When running as PID1 the above kill doesn't have any effect (execution simply passes through it, contrary
// to a non-PID1 process where execution stops at kill and switches over to signal handling). Also as PID1
// we must unblock the thread that received the original signal otherwise the process will never terminate.
gBlockForFatal = false;
exit(signal_number);
}