Ghosts of Unix past, part 2: Conflated designs
Posted Nov 12, 2010 23:08 UTC (Fri) by giraffedata
In reply to: Ghosts of Unix past, part 2: Conflated designs
Parent article: Ghosts of Unix past, part 2: Conflated designs
I agree that in many cases, the non-blockingness is a property of the read, and not the file descriptor. But making it an argument of read() instead of a file descriptor attribute would violate a fundamental Unix principle, covered in the first article of this series: that of the generic byte stream.
In some cases, you want a piece of code to be agnostic of blocking, just as it is agnostic to socket vs tape drive. The code neither knows nor cares whether its read will block or return zero bytes. It's the caller's business alone.
So I would like to see both. The pread() situation is quite analogous: pread() extends the simple byte stream with the concept of stream position, but another program can still remain agnostic to position, using classic read() while its caller manipulates position with lseek().
to post comments)