Is there any expert out there that can help me with the following?
I have the following system calls in C:
access()
unlink()
setsockopt()
fcntl()
setsid()
socket()
bind()
listen()
I want to know if they may fail with error code -1 and errno EINTR/EAGAIN.
Should I have to handle EINTR/EAGAIN for these?
The documentation do not refer anything related to EINTR/EAGAIN but many people I see handle it.
Which is the correct?
Here is how I register signal handlers : https://gitorious.org/zepto-web-server/zepto-web-server/source/b1b03b9ecccfe9646e34caf3eb04689e2bbc54dd:src/signal-dispatcher-utility.c
With this configuration: https://gitorious.org/zepto-web-server/zepto-web-server/source/b1b03b9ecccfe9646e34caf3eb04689e2bbc54dd:src/server-signals-support-utility.c
Also here is a commit that I added some EINTR/EAGAIN handling in some system calls that I know that return EINTR or EAGAIN : https://gitorious.org/zepto-web-server/zepto-web-server/commit/b1b03b9ecccfe9646e34caf3eb04689e2bbc54dd
The EINTR error indicates that an interrupted system call has occurred. This error is returned when your process has been signaled, and a signal handler has been called to process it, and that handler has returned from its call.
Many system calls will report the EINTR error code if a signal occurred while the system call was in progress. No error actually occurred, it's just reported that way because the system isn't able to resume the system call automatically.
EINTR is the error which so-called interruptible system calls may return. If a signal occurs while a system call is running, that signal is not ignored. If a signal handler was defined for it without SA_RESTART set and this handler handles that signal, then the system call will return the EINTR error code.
Interruption of a system call by a signal handler occurs only in the case of various blocking system calls, and happens when the system call is interrupted by a signal handler that was explicitly established by the programmer.
Unless you install an interrupting signal handler (one installed with sigaction
omitting the SA_RESTART
flag, or one installed with the signal
function on some systems) you should not expect to see EINTR
at all.
Among your particular list of functions, I don't see any that could experience EINTR
anyway except fcntl
, and for it, only when it's used for locking. The link in John's answer should be helpful answering questions about specific functions, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With