Re: read() and EOF



David Mathog <mathog@xxxxxxxxxxx> writes:
The linux man pages say that read() returns a 0 at end of file. Is
there a guarantee that it will continue to do that on subsequent
read() from the same fd, or is it conformant to return a 0 once, and
then an error after that? (I vaguely recall seeing that there are
situations where EOF is only returned once, but I could be mistaken.)

One such situation would IIRC be a TCP socket which has been closed by
remote. The read will return an EOF indicator once and an error if
another read is attempted after this.
.