read() details

From: Simon Kirby (
Date: Thu Jul 26 2001 - 16:47:19 EST

Just some things I've always wondered about...

Is it safe to assume that when a single read() call of x bytes a file
(the file being locked against other processes appending to it) returns
less than x bytes, the next read() will always return 0? If so, is it
portable to make such an assumption?

...Or is it always better to make sure read() returns 0 before assuming
EOF, perhaps because the kernel may want to promote contiguous-page
read()s or for some other reason?

On a related note, would there be a win in altering the first read() size
(at the beginning of a read loop) to allow the kernel to serve the
subsequent read requests from contiguous pages? (This is assuming that
an lseek() happened first which would misalign the further read()s with
page boundaries.)


[ Stormix Technologies Inc. ][ NetNation Communications Inc. ]
[ ][ ]
[ Opinions expressed are not necessarily those of my employers. ]
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Tue Jul 31 2001 - 21:00:29 EST