[Haskell-cafe] Blocking IO & FIFOs

Jason Dusek jason.dusek at gmail.com
Sat Oct 20 19:02:22 CEST 2012

2012/10/20 Donn Cave <donn at avvanta.com>:
> Quoth Jason Dusek <jason.dusek at gmail.com>,
> ...
>> For my application, it's important to be able to run multiple
>> queries against the same Bash session. Waiting for Bash to shut
>> down is thus not a viable way to finalize the response.
> You could redirect to disk files and also use a pipe to wait for exit.
> I suppose you redirect I/O for individual queries by applying shell
> redirections to the command?  So like this,
>    uname -a > /tmp/cmd1 2> /tmp/cmd2 7> /tmp/exitpipe
> ... then read from /tmp/exitpipe, ignore empty result and read command
> outputs from the disk files.

If I could somehow arrange to detect EOF when /tmp/exitpipe is
closed, then I might as well redirect 1 and 2 to FIFOs and wait
for them to EOF, collecting the output.

However, all of my experiments suggest that there is simply no
way in Haskell to detect the closing of the write end of a FIFO.
With `openFileBlocking', one can detect when a FIFO is *opened*;
but not when it is closed.

Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B

More information about the Haskell-Cafe mailing list