[mod.std.unix] You wanted weirdnix....

std-unix@ut-sally.UUCP (12/04/86)

References:

From: scgvaxd!stb!michael@seismo.UUCP
Date: Tue Nov 25 17:39:33 1986


Ok, lets look at read() and write().
1. There is no requirement that anything written will be available for a
read().
2. There is no requirement that read/write return everything that they can.

In general, you can't require this. The terminal lines are a good example; 
writting to a terminal will not result in it being readable; the terminal
drivers only return a line at a time no matter how much is requested. Or
at least, thats what the docs say (I've never actually tested it, but it
seems that if it were false, then type ahead would not work as well.)

In general, it is probably safe to require that anything written to a file
should be available to a subsequent read provided that the read is done on
a file descriptor corresponding to the same name, or a link to the same
named file that was written to, all providing that it is a regular file.
Certainly not for device or special files.

Incidently, don't think that 2 is obvious; my first unix programs assumed
that the O/S would return a number of bytes so that the reads would be
re-aligned on a 512 byte boundary, and that I had to call read() multiple
times until I had gotten everything. I was quite suprised to find that
other people had written stuff that did not do this, and even more
suprised to find that it actually worked. No :-)

		Michael Gersten



Volume-Number: Volume 8, Number 63