On Tue, 2 Sep 2008, Jesus Cea wrote:
Indeed. read(0) is quite often generated as an edge case when one is computing buffer sizes, and returning an empty string is most definitely the right thing to do here (otherwise some application code becomes more complex by having to avoid calling read(0) at all).
How do you differenciate between that empty string (when doing "read(0)"), from EOF (that is signaled by an empty string)?.
Why would you expect a difference between reading 0 bytes at EOF and reading 0 bytes anywhere else? If you read(4) when at offset 996 in a 1000-byte file I doubt you expect any special notification that you are now at EOF. The Unix read() system call doesn't treat EOF as special other than it won't return bytes from "beyond" EOF and therefore even when reading a regular file could return fewer (including 0) bytes than asked for in the call. Isaac Morland CSCF Web Guru DC 2554C, x36650 WWW Software Specialist