Home

EWOULDBLOCK

EWOULDBLOCK is an errno value used by Unix-like systems to indicate that a non-blocking I/O operation would block if it were allowed to proceed. It is most commonly encountered when performing read or write operations on a file descriptor that has been opened with the O_NONBLOCK flag, or when working with non-blocking sockets, pipes, or fifos.

In practice, a non-blocking I/O call that cannot complete immediately returns an error of -1 with errno

Typical usage involves non-blocking I/O alongside readiness notifications. Programs may use mechanisms such as select, poll,

Notes:

- EWOULDBLOCK is most relevant to non-blocking file descriptors, including sockets, pipes, and fifos.

- On regular files, operations typically do not produce EWOULDBLOCK because they are not constrained by readiness

- For portability, many code bases check for both EWOULDBLOCK and EAGAIN.

See also EAGAIN, O_NONBLOCK, errno.

set
to
EWOULDBLOCK.
Because
EWOULDBLOCK
is
often
implemented
as
the
same
value
as
EAGAIN,
many
systems
treat
these
two
errors
equivalently.
For
portability,
code
frequently
checks
for
both
EWOULDBLOCK
and
EAGAIN
when
handling
non-blocking
I/O.
epoll,
or
kqueue
to
wait
for
a
file
descriptor
to
become
ready
for
reading
or
writing,
and
then
retry
the
operation.
When
a
call
returns
EWOULDBLOCK,
the
appropriate
response
is
usually
to
wait
for
the
descriptor
to
become
ready
and
retry
later,
or
to
implement
a
backoff
strategy.
in
the
same
way
as
non-blocking
I/O
on
sockets
or
pipes.