Consider this situation:
- A process sets up a signal handler for several signals:
- Let's say the signal handler for SIGUSR1 is called handle_sigusr.
- Now the process is running a part of its code, a function foo:
- foo issues a system call, say the open(2)
- The system call fails returning -1
- errno gets set to the positive integer 13 reflecting the error permission denied (errno macro EACCES).
- The system call's error-handling code calls perror(3) to emit the English error message.
All this seems innocent enough, yes. However, now let's consider signals in the mix; check out the following scenario:
- <...>
- foo issues a system call, say the open(2).
- The system call fails returning -1.
- errno gets set to the positive integer ...