In the specific case of sockets, read(2)
is considered to be a slow syscall because it can block forever; therefore if a signal is received for which a signal handler has been set up, one of two things can happen:
- If the signal handler was set with the
SA_RESTART
flag in the sa_flags
field of struct sigaction
, then the syscall is automatically restarted after (and if) the handler returns (cases where the handler does not return include, but are not limited to, handler code that calls exit(3)
or uses longjmp(3)
/ setjmp(3)
); user code does not see EINTR
in this case.
- If the
SA_RESTART
flag was not set, the syscall returns prematurely and errno
is set to EINTR
.
For the generic rules, see man 7 signal
, pay particular attention to the section Interruption of system calls and library functions by signal handlers