Gorka guardiola wrote:
> A 0 read means eof. ...

Actually (on Unix) it never "meant" EOF, that was just a convention.
Typing ^D on a terminal, for example, would delimit the input the
same as newline but without inserting a character; thus ^D after a
newline (or after a preceding ^D) would produce a 0-length record,
returning length 0 from a read. (just as typing "123^D" would
produce a 3-byte record without newline). An attempt to read the
next N bytes from a disk file when already at end of file would
return 0 rather than error, as a convenient way to indicate "no
more data" that was consistent with the terminal-handler convention.

It was important that such "EOF" was not "sticky", so if more
input became available it could be read subsequently. (The C
standard as of 1999 decided to make stdio EOF condition "sticky",
at least until a new positioning request, to reduce the incidence
of a common class of bugs.)