...
POSIX recommends sigaction()
and deprecates signal()
. Unfortunately, sigaction()
is not C99-compliant and is not supported on some platforms, including Windows.
Compliant Solution (Windows)
There is no safe way to implement persistent signal handler behavior on Windows platforms, and consequently should not be attempted. In cases where a design depends on this behavior, and the design can not be altered, it may be necessary to claim a deviation from the rule after completing an appropriate risk analysis.
Exceptions
SIG34-EX1: On a machine with persistent signal handlers, it is safe for a handler to modify the behavior for its own signal. This would include having the signal be ignored, reset to default behavior, or handled by a different handler. A handler assigning itself to its own signal is also safe, as it is a no-op. The handler is impervious to a race condition because multiple invocations of its signal will merely cause it to "interrupt itself" until it manages to reassign its signal.
...