[Haskell-cafe] I/O system brokenness with named pipes

John Goerzen jgoerzen at complete.org
Fri Apr 11 09:15:37 EDT 2008

On Fri April 11 2008 7:53:12 am Brandon S. Allbery KF8NH wrote:
> On Apr 11, 2008, at 6:33 , Don Stewart wrote:
> >> But I can't use writeFile to write data to it.  Worse, it returns:
> >>
> >> *** Exception: /tmp/bakroller.zD0xHj/fifo: openFile: does not exist
> >>     (No such device or address)
> >
> > Hmm, I can get this to work, but only if I have another process
> > waiting
> > on the pipe already:
> Yep; that's one of the tricky parts of FIFOs.  If you don't have the
> read side *always* open, it behaves very nonintuitively.  (But with
> the read side always open, you will never receive an EOF.)
> This has nothing to do with Haskell; it's just the way FIFOs work.

I wonder if we could document this behavior.  I rarely use non-blocking I/O 
from C, and Haskell hides the fact that it's doing this, so the behavior is 

Actually, better yet, I wonder if we could *fix* this behavior.  Most 
programs can take a FIFO as arguments in a standard way, and it seems to me 
that this violates the principle of least surprise.  

Unfortunately, since we're talking about open here, we can't use select() or 
poll().  But I wonder if we couldn't use stat() to determine if something is 
a named pipe, and if so, enter a loop where we try to open it periodically?

-- John

More information about the Haskell-Cafe mailing list