[Haskell-beginners] Named Pipes Et Cetera
Brandon S Allbery KF8NH
allbery at ece.cmu.edu
Fri Dec 3 20:59:21 CET 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/23/10 07:55 , matthew coolbeth wrote:
> Hello, all.
>
> Three questions:
>
> 1> What, if anything, can I do in a Haskell program to do blocking
> reads from a Linux FIFO? For the curious, there is a small program
> below that doesn't block, but immediately terminates because of an EOF
>
> 2> How could I have found the answer to this question on my own? (The
> documentation that Google found for me was not completely adequate)
This isn't specific to Haskell, but rather to Unix/POSIX FIFOs. In general,
they often don't do what you want. :)
The short version is: the "server" end should open read-write, because the
last close by a writer will send an EOF and tear down the connection so that
it can't be reused without closing and reopening. This does mean you can't
actually receive EOFs if you intend to block on the FIFO, so design whatever
protocol you plan to use with this in mind.
That said, it sounds like GHC's I/O manager is handling this incorrectly;
what you wrote should in fact block waiting for a writer, output everything
it reads, then exit when the writer goes away. If it's GHC7, then likely
someone broke FIFO handling (again... very few people seem to understand the
care and feeding of FIFOs) in the new I/O manager.
- --
brandon s. allbery [linux,solaris,freebsd,perl] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkz5TBkACgkQIn7hlCsL25URDQCdGisbjpa65EeE83CZcyXRLuru
Py4AoIB17qhlagBd3JxggakvjV23+6pC
=mphl
-----END PGP SIGNATURE-----
More information about the Beginners
mailing list