[Haskell-cafe] ptys and hGetContent problem

Mathijs Kwik bluescreen303 at gmail.com
Mon Mar 8 14:38:19 EST 2010

Hi all,

I found this blogpost from Bryan O'Sullivan
and I wanted to try it out.

Before moving to an interactive command (which needs pty), I just did
a small test for "ls -l /" to see if it worked.
I got it to compile, but when running, it throws an exception when
reaching the end of the output (in this case because I evaluate the
length to force reading all).
Main: /dev/ptmx: hGetContents: hardware fault (Input/output error)

Please have a look at the hpaste to see what I did:

What's wrong? :)
My guess is that hGetContents doesn't receive a nice EOF when the
process exits (ls doesn't stay around waiting for input), but I have
no idea on how to fix this.

And further...
If I do want to use an interactive program which needs input, how do I
send ctrl-d or ctrl-c?
tail -f needs ctrl-c (or I need to kill the process)

Thanks for any help

I know about libexpect, it's not useful for what I wanna do (multiple
processes, having 'answers' from 1 be used to decide what to input the
other, without ending the 'answer' process)

More information about the Haskell-Cafe mailing list