Home

EAGAIN

EAGAIN is an errno value defined by POSIX that indicates the resource or operation is temporarily unavailable and should be retried later. It is most commonly encountered with non-blocking I/O or asynchronous operations, where a call would block if it waited for the resource.

In practice, EAGAIN appears when a non-blocking file descriptor cannot complete an operation immediately. For example,

Relation to EWOULDBLOCK: on many systems, EWOULDBLOCK is defined as an alias of EAGAIN, sharing the same

Handling and patterns: code that performs non-blocking I/O often checks for EAGAIN (or EWOULDBLOCK) and then

Platform considerations: while Unix-like systems generally use EAGAIN, Windows handles non-blocking socket operations with a separate

reading
from
a
non-blocking
socket
with
no
data
available,
or
writing
when
the
output
buffer
is
full,
may
return
-1
and
set
errno
to
EAGAIN.
In
these
cases
the
correct
response
is
typically
to
try
again
later
or
to
wait
for
the
descriptor
to
become
ready
(using
mechanisms
such
as
select,
poll,
or
epoll).
numeric
value
and
meaning.
This
reflects
historical
usage
where
socket
operations
could
set
EWOULDBLOCK
for
non-blocking
operations;
POSIX
treats
EAGAIN
as
the
standard
name,
while
EWOULDBLOCK
remains
a
compatibility
synonym
in
some
environments.
retries
the
operation
after
awaiting
readiness.
It
is
important
to
distinguish
EAGAIN
from
other
errors
such
as
EINTR
(interrupted
by
a
signal);
EINTR
typically
indicates
the
operation
should
be
retried,
but
the
appropriate
response
depends
on
context
and
the
specific
system
call.
error
code
(WSAEWOULDBLOCK)
rather
than
EAGAIN.
Regular
files
on
many
systems
do
not
usually
return
EAGAIN,
since
they
are
typically
always
ready
for
I/O.
See
also:
EINTR,
EPOLL,
SELECT,
WSAEWOULDBLOCK.