...
This rule is a special case of SIG31-C. Do not access shared objects in signal handlers. The object designated by errno
is of static storage duration and is not a volatile sig_atomic_t
. As a result, performing any action that would require errno
to be set would normally cause undefined behavior. The C Standard in subclause 7.14.1.1 paragraph 5 makes a special exception for errno
in this case, saying the only thing that is allowed to go wrong is that errno
can take on an indeterminate value. This special exception makes it possible to call signal()
from within a signal handler without risking unrestricted undefined behavior, but the handler, and any code executed after the handler returns, must not depend on the value of errno
being meaningful.
...