90

As in the title what does EAGAIN mean?

Good Person
  • 1,437
  • 2
  • 23
  • 42
David van Dugteren
  • 3,879
  • 9
  • 33
  • 48

5 Answers5

97

EAGAIN is often raised when performing non-blocking I/O. It means "there is no data available right now, try again later".

It might (or might not) be the same as EWOULDBLOCK, which means "your thread would have to block in order to do that".

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • 3
    According to IEEE 1003.1, `EAGAIN` may be the same as `EWOULDBLOCK`. http://www.opengroup.org/onlinepubs/000095399/basedefs/errno.h.html – Fred Foo Oct 30 '10 at 11:09
  • 10
    What I mean is: a portable program should not rely on them being distinct. – Fred Foo Oct 30 '10 at 11:12
  • 4
    On Linux EAGAIN & EWOULDBLOCK are the same value but truly portable code should check both. – hookenz May 27 '14 at 21:16
  • 1
    It might be because you reached a ulimit soft/hard resource such as threads, files or network connections. – Buzut Apr 28 '16 at 10:39
27

Using man 2 intro | less -Ip EAGAIN:

     35 EAGAIN Resource temporarily unavailable.  This is a temporary condi-
         tion and later calls to the same routine may complete normally.
turfx
  • 271
  • 3
  • 2
7

What it means is less important. What it implies:

  • your system call failed
  • nothing happened (system calls are atomic, and this one just did not happen)
  • you could try it again (it could fail again, possibly with a different result)
  • or you could choose otherwise.

The whole thing about EAGAIN is that your process is not blocked inside the system call; it has the right to choose: either retry or do something useful.

wildplasser
  • 43,142
  • 8
  • 66
  • 109
  • Do you have a source to support the "system calls are atomic" claim? I find contradictory results – sehe Jul 10 '18 at 11:20
0

Excerpt errno(3) - Linux manual page:

EAGAIN Resource temporarily unavailable (may be the same value as EWOULDBLOCK) (POSIX.1-2001).

Use case: When epoll in ET mode, only wait after read or write return EAGAIN

douyu
  • 2,377
  • 2
  • 14
  • 27
-1

According to this, it means "Operation would have caused the process to be suspended."

thelost
  • 6,638
  • 4
  • 28
  • 44