When to use HANDLE_EINTR or HANDLE_EAGAIN?

I write a web server in C, and I often use system calls that return -1 on error and set the errno variable to the appropriate value. Some system calls may return EINTR and / or EAGAIN. I have two shells HANDLE_EINTR, HANDLE_EAGAIN, which use both of these error values ​​and retry the system call.

Man pages are usually referenced if a system call returns EINTR and / or EAGAIN, but for some system calls this is really not the case. Also, some system calls can return EINTR / EAGAIN not directly, but through the failure of other system calls that can be used in it.

I would like to ask if I can use HANDLE_EINTR and / or HANDLE_EAGAIN no matter what the API declares (which is not always completed).

In addition, I know from Google people that using HANDLE_EINTR with the close system call (although the API refers to its use) is not very good, so I do not use it. Are there other system calls that have this behavior?

Thank.

+4
source share
1 answer

The semantics are EINTRalso EAGAINdefined correctly. If a particular system call is not documented as potentially returning a specific one errno, there is no harm in having a handler for it.

, errno s, , , errno.

0

All Articles