Manual page read(2) at https://man7.org/linux/man-pages/man2/read.2.html, states:
On success, the number of bytes read is returned (zero indicates end of file)….It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal.
How do we differentiate EOF from a read of 0 characters that is simply less than the number of bytes requested?
I have blissfully been using the read syscall for decades and now I have made the mistake of reading the manual. Am I missing something?
On success, the number of bytes read is returned (zero indicates end of file)….It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal.
How do we differentiate EOF from a read of 0 characters that is simply less than the number of bytes requested?
I have blissfully been using the read syscall for decades and now I have made the mistake of reading the manual. Am I missing something?