exitWithDefaultSignalHandler() should block until signal handler returns (#464)

raise() system call does the same as kill() system call in a
single-threaded program.
In a multithreaded program, it does the same as pthread_kill() which
ensures that if the signal causes a handler to be called, raise() will
return only after the signal handler has returned.
This commit is contained in:
ablangy 2022-11-10 17:34:07 +01:00 committed by GitHub
parent 21195751be
commit 0c09462e4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,7 +230,7 @@ namespace g3 {
std::cerr << "\n\n" << __FUNCTION__ << ":" << __LINE__ << ". Exiting due to " << level.text << ", " << signal_number << " \n\n" << std::flush; std::cerr << "\n\n" << __FUNCTION__ << ":" << __LINE__ << ". Exiting due to " << level.text << ", " << signal_number << " \n\n" << std::flush;
kill(getpid(), signal_number); raise(signal_number);
// When running as PID1 the above kill doesn't have any effect (execution simply passes through it, contrary // 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 // to a non-PID1 process where execution stops at kill and switches over to signal handling). Also as PID1