...
the value of
errnois referred to after a signal occurred other than as the result of calling theabortorraisefunction and the corresponding signal handler obtained aSIG_ERRreturn from a call to thesignalfunction.
(See undefined behavior 133 of Annex J.)
A signal handler is allowed to call signal(), and if that fails, signal() returns SIG_ERR and sets errno to a positive value. However, if the event that caused a signal was external (not the result of the program calling abort() or raise()), the only functions the signal handler may call are _Exit() or abort(), or it may call signal() on the signal currently being handled, and if signal() fails, the value of errno is indeterminate.
...