[Haskell-cafe] How can I avoid buffered reads?

Donn Cave donn at avvanta.com
Thu Dec 6 23:14:07 CET 2012


Quoth Brandon Allbery <allbery.b at gmail.com>,
> On Thu, Dec 6, 2012 at 3:24 PM, Tristan Seligmann
> <mithrandi at mithrandi.net>wrote:
>>> On 29 Nov 2012 12:27 PM, "Leon Smith" <leon.p.smith at gmail.com> wrote:
>>> System.Posix.IO and Foreign.    This appears to work,  but for better or
>>> worse,   it is using blocking calls to the "read" system call and is not
>>> integrated with GHC's IO manager.   This shouldn't be an issue for my
>>> purposes,  but I suppose it's worth pointing out.
>>
>> Reading from an fd corresponding to an actual file is always blocking.
>> select() will always indicate that the fd is ready for reading and writing,
>> and I think epoll() will refuse to operate on the fd at all.
>
> This; it's a longstanding gripe among those of us who use network
> filesystems heavily, since it's entirely possible those reads *will*
> block... but the usual architecture of Unix-like kernel filesystem code
> doesn't provide any way to see it or do anything about it.

A wretched state of affairs indeed, but is that the same problem?

While I guess /dev/urandom isn't supposed to block, so it would look
about the same to select(2) either way, /dev/random is select-able, true?
If GHC IO is using blocking I/O on everything opened by name, on the
assumption it's talking to a filesystem, then that looks to me like
GHC's error, not UNIX's.

	Donn



More information about the Haskell-Cafe mailing list