Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



EINTR 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)


Yes, 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.


More on what EINTR is for: http://250bpm.com/blog:12




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: