[Haskell-cafe] PseudoTerminals and Handles (again)

Mathijs Kwik bluescreen303 at gmail.com
Wed Mar 10 03:20:11 EST 2010

Hi All,

A few days ago, I got started with the code found on this blogpost:

On my system, I found that using pseudoterminals as handles did not work.
Reading output and writing input works fine, it's just that finding
"the end of the stream" seems to break.
This means that I can read all output up to the last character
outputted by the other process, but the string doesn't end there.
Instead it's throwing:
fdReadBuf: hardware fault (Input/output error)

Using normal pipes (no pty), this does work as expected.

My guess is that I should somehow setup the fd or the pty a little
more before starting the child process.
Set them to nonblock/block, read/write mode, setTerminalAttribute,
stuff like that. And maybe it matters when to change settings (before
forking / after forking / in the child), or to change the master or
the child...
I don't know very much about this stuff but since the rest seems to
work fine it just seems to be a problem with how the child announces
it's finished writing to the fd.

Is there anyone who got this to work somehow?
Or is there a way to somehow trick hGetContents and friends to just
treat the "hardware fault" as EOF?


PS: I'm using ghc 6.12.1 on x86_64  (ubuntu) by the way

More information about the Haskell-Cafe mailing list