What does errno 4 (EINTR) mean?

 
Could be also:
ConstantTypeOS
ERROR_TOO_MANY_OPEN_FILESWin32 errorWindows
KERN_INVALID_ARGUMENTKern returnMac
ippStsInvZeroIntel Ipp StatusAny
INVALID_DATA_ACCESS_TRAPBugCheck CodeWindows
Previous Next
ESRCH EIO

EINTR

Meaning and context of EINTR

If a signal handler is invoked while a system call or library function call is blocked, then either:

  • the call is automatically restarted after the signal handler returns; or
  • the call fails with the error EINTR.

Which of these two behaviors occurs depends on the interface and whether or not the signal handler was established using the SA_RESTART flag. The details vary across UNIX systems; below, the details for Linux.

If a blocked call to one of the following interfaces is interrupted by a signal handler, then the call is automatically restarted after the signal handler returns if the SA_RESTART flag was used; otherwise the call fails with the error EINTR:

  • read(2), readv(2), write(2), writev(2), and ioctl(2) calls on "slow" devices. A "slow" device is one where the I/O call may block for an indefinite time, for example, a terminal, pipe, or socket. If an I/O call on a slow device has already transferred some data by the time it is interrupted by a signal handler, then the call will return a success status (normally, the number of bytes transferred). Note that a (local) disk is not a slow device according to this definition; I/O operations on disk devices are not interrupted by signals.
  • open(2), if it can block (e.g., when opening a FIFO; see fifo(7)).
  • wait(2), wait3(2), wait4(2), waitid(2), and waitpid(2).
  • Socket interfaces: accept(2), connect(2), recv(2), recvfrom(2), recvmmsg(2), recvmsg(2), send(2), sendto(2), and sendmsg(2), unless a timeout has been set on the socket (see below).
  • File locking interfaces: flock(2) and the F_SETLKW and F_OFD_SETLKW operations of fcntl(2)
  • POSIX message queue interfaces: mq_receive(3), mq_timedreceive(3), mq_send(3), and mq_timedsend(3).
  • futex(2) FUTEX_WAIT (since Linux 2.6.22; beforehand, always failed with EINTR).
  • getrandom(2).
  • pthread_mutex_lock(3), pthread_cond_wait(3), and related APIs.
  • futex(2) FUTEX_WAIT_BITSET.
  • POSIX semaphore interfaces: sem_wait(3) and sem_timedwait(3) (since Linux 2.6.22; beforehand, always failed with EINTR).
  • read(2) from an inotify(7) file descriptor (since Linux 3.8; beforehand, always failed with EINTR).

Diagnosing EINTR on Solaris

EINTR is errno value 4 in the current AllStat Solaris data. Its recorded meaning is “Interrupted system call”. Save errno immediately after the failed function, because logging, allocation, cleanup, or another library call can overwrite the thread-local value.

Call-specific evidence for EINTR

  • Record the exact system or library call, return value, descriptor or pathname, open flags, process credentials, resource controls, and whether the descriptor was nonblocking.
  • Use the Solaris manual page for the failing call to determine which argument or kernel state can produce EINTR; a portable errno name alone is not enough.
  • For transient conditions, wait for the documented readiness or resource transition instead of spinning; for invalid state or permissions, correct the caller or environment first.

When comparing EINTR across operating systems, keep the symbolic name and numeric value separately. Solaris and other UNIX implementations can assign different numbers or expose implementation-specific conditions under the same broad POSIX category.

Official references for EINTR


Looking for a different code? Search another status or error code.