A signal handler should not reassert its desire to handle its own signal. This is often done on non-persistent platforms, that is, platforms that, upon receiving a signal, unbind the signal to default behavior before calling the bound signal handler. See SIG01-A. Understand implementation-specific details regarding signal handler persistence.
A signal handler may only call signal()
if it does not need to be asynchronous-safe (in other words, all relevant signals are masked, and consequently it may not be interrupted.)
...
Code Block | ||
---|---|---|
| ||
void handler(int signum) { #ifndef WINDOWS signal(signum, SIG_DFL); #endif /* handle signal */ } /* ... */ signal(SIGUSR1, handler); |
...
Risk Assessment
Two signals in quick succession can trigger the race condition on non-persistent platforms, causing the signal's default behavior despite a handler's attempt to override it.
...