Andreas Oberritter <andreas@oberritter.de> wrote:
On Tue, 2003-01-14 at 11:00, Clemens Kirchgatterer wrote:
If you always read 4096 bytes then you will always receive whole
sections.
... assuming read() does not fail and return -1, of course.
but you may also read less, IMHO. i.e. when EINTR occours.
read() will then return -1 and the content of the buffer should be
discarded, because it is not possible to tell how much data (if any)
has been copied to it. The next succeeding read will copy a complete
section to the buffer.
man(2) read:
On success, the number of bytes read is returned (zero indicates
end of file), and the file position is advanced by this number. 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 [..] or because read() was interrupted by a signal.
[..]
POSIX allows a read that is interrupted after reading some data to
return -1 (with errno set to EINTR) or to return the number of bytes
already read.
(end man)
i don't really know if this is of any relevance for the driver. could
you please comment on that? i think, based on manpage, it IS possible,
that read returns with less then available bytes, caused by a signal,
without returning -1.
it would probably be possible and POSIX conform, but why would you want
to have the required overhead and exception checking in the driver and
your software? Delivering complete sections is just the most convinient way.