3 ms·
EINTR is only "needed" because of the situation where a call is made to a blocking system call like read, and a signal is received before it completes. It needs
by nitwit005 10y ago
EINTR is only "needed" because of the situation where a call is made to a blocking system call like read, and a signal is received before it completes. It needs to cancel the blocking call so that it can run the signal handler.
If you get rid of signals, you wouldn't need EINTR. Even with signals, what people do 99% of the time is just retry the system call immediately. It would probably have been much better to have it do so automatically by default, avoiding exposing EINTR to most users.
- JdeBP 10y ago... and, thence, SA_RESTART.
- to3m 10y agoMore on what EINTR is for: http://250bpm.com/blog:12 http://250bpm.com/blog:12
- noselasd 10y agoEINTR is retried automatically if you use sigaction() and set the SA_RESTART flag. If you use signal() instead of sigaction() it depends on your OS whether EINTR is automatically retried - never use signal(). (There's a few exceptions still - partial completed syscalls, e.g. a signal can cause read() to return partial data or sleep() to return before it should - neither case gives you EINTR though)
- adrianratnapala 10y agoYes, but how does the Plan9 "notify" mechanism help with any of that? It seems to just be a tidied up version of signals, and therefore "needs" to do EINTR in much the same way as Unix.