[Haskell-cafe] writing to a fifo when the reader stops reading

Brandon S Allbery KF8NH allbery.b at gmail.com
Mon Mar 14 07:33:13 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/13/11 03:16 , briand at aracnet.com wrote:
> ghc: fdWriteBuf: resource vanished (Broken pipe)
> 
> which make sense, sort of.  I write a value, let's say 10, and the
> reader reads it.  It's the last value so it "closes" the fifo.
> 
> Now there's nothing reading, so when I get to threadWaitWrite, I would
> expect the program to wait, just as it does when it starts up and there
> is no reader.

FIFOs don't work that way; like a regular pipe, once all readers go away it
doesn't work any more.  You need to open it read-write initially to keep a
reader around.  Haskell has no control over this:  it's how they're defined
to work.

In general, trying to use a FIFO like an AF_UNIX socket is a mistake.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]    allbery.b at gmail.com
system administrator  [openafs,heimdal,too many hats]                kf8nh
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk19tqkACgkQIn7hlCsL25VxGwCgsInAy4YJhOA2Ca/tQTRd0Cjs
NmAAn2hjqtQm0/eZXVoLM8GMCMv+yxR4
=SDd8
-----END PGP SIGNATURE-----



More information about the Haskell-Cafe mailing list