You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using signal handlers it is essential to care that called functions are async-signal-safe. Beside that, if the called function may update errno, the signal handler should save and restore the value of errno.
To cite "The Linux Programming Interface" by Michael Kerrisk, ISBN-13: 978-1-59327-220-3, Chapter 21, page 427:
Use of errno inside signal handlers
Because they may update errno, use of function listed in Table 21-1 can never-
theless render a signal handler nonreentrant, since they may overwrite the errno
value that was set by a function called from the main program. The workaround is
to save the value of errno on entry to a signal handler that uses any of the function
in Table 21-1 and restore the errno value on exit from the handler, as in the following-
ing example:
void
handler(int sig)
{
int savedErrno;
savedErrno = errno;
/* Now we can execute a function that might modify errno */
errno = savedErrno;
}
The referenced Table 21-1 is a list of async-signal-safe functions as specified by POSIX.
This problem affects (probably among others) the example interrupt.c:
When using signal handlers it is essential to care that called functions are async-signal-safe. Beside that, if the called function may update errno, the signal handler should save and restore the value of errno.
To cite "The Linux Programming Interface" by Michael Kerrisk, ISBN-13: 978-1-59327-220-3, Chapter 21, page 427:
The referenced Table 21-1 is a list of async-signal-safe functions as specified by POSIX.
This problem affects (probably among others) the example interrupt.c:
write() may update errno. Thus the signal handler should save and restore the errno value.
The text was updated successfully, but these errors were encountered: