use compliant sig_atomic_t for signal handler, use _Exit

This commit is contained in:
Robert Müller 2021-10-15 18:43:49 +02:00 committed by Dennis Felsing
parent a69852bdfc
commit 259a449b67

View file

@ -50,7 +50,7 @@
#include <signal.h> #include <signal.h>
volatile bool InterruptSignaled = false; volatile sig_atomic_t InterruptSignaled = 0;
CSnapIDPool::CSnapIDPool() CSnapIDPool::CSnapIDPool()
{ {
@ -3608,9 +3608,9 @@ static CServer *CreateServer() { return new CServer(); }
void HandleSigInt(int Param) void HandleSigInt(int Param)
{ {
if(InterruptSignaled) if(InterruptSignaled)
exit(1); _Exit(1); // exit is not async-signal-safe and must not be called from a signal handler
else else
InterruptSignaled = true; InterruptSignaled = 1;
} }
int main(int argc, const char **argv) // ignore_convention int main(int argc, const char **argv) // ignore_convention