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

briand at aracnet.com briand at aracnet.com
Mon Mar 14 15:44:45 CET 2011


On Mon, 14 Mar 2011 02:33:13 -0400
Brandon S Allbery KF8NH <allbery.b at gmail.com> wrote:

> -----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.

ok,  I wanted to make sure that I wasn't missing something on the
Haskell side.

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


and using a socket doesn't really make sense because everything is
running on the same host, always will be, and using sockets will
unnecessarily complicate things.  although it's not that bad and works
really well.

I'll go figure out a different strategy.

Thank you,

Brian



More information about the Haskell-Cafe mailing list