mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-13 10:42:56 +01:00
Unblock faulting thread signal handler after log flush is complete (#419)
This commit is contained in:
parent
9009e109e9
commit
c51128f051
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user