Re: Handling read() errors
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 5 Apr 2007 12:23:16 GMT
Krivenok Dmitry <krivenok.dmitry@xxxxxxxxx> wrote:
Suppose read() system call returns -1.
There are many causes of the error.
I exactly know that if errno = EINTR, then I can safety restart
system call as follows:
while( (rc = read(sock, buf, count)) == -1 and errno == EINTR)
{
// Do nothing.
}
Are there another cases when I can safety restart read()?
If so, what errno values correspond to these cases?
If you have opened the file in non-blocking mode you may
get EAGAIN or EWOULDBLOCK if there were no data to be read.
This is probably the second "normal" case where calling
read() again makes sense. If there are others depends on
the what kind of object you're reading from - if you're
reading from a socket and you get ETIMEDOUT because the
transmission timed out there might be some reasons to call
read() again. And if your system is struggling because it
doesn't have enough memory you may get ENOBUFS or ENOMEM.
In that case you also might decide to try your luck again,
perhaps after a short pause to give the system time re-
claim enough memory.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: Handling read() errors
- From: Krivenok Dmitry
- Re: Handling read() errors
- References:
- Handling read() errors
- From: Krivenok Dmitry
- Handling read() errors
- Prev by Date: Handling read() errors
- Next by Date: Re: Handling read() errors
- Previous by thread: Handling read() errors
- Next by thread: Re: Handling read() errors
- Index(es):
Relevant Pages
|