[Haskell-cafe] file descriptors and handles

Mathijs Kwik bluescreen303 at gmail.com
Mon Mar 8 14:26:06 EST 2010


Hi all,

Today I had a look at chapter 20 of RWH.
The extended example (stripped down HSH) in the end is great.
I think I understand it, but I have some questions left:

the master process closes the client-sided FD's.
it uses fdToHandle for the other sides of the pipe to get a handle to
stdIn and stdOut on the client process.
it writes to the stdIn handle and closes it afterwards.
- doesn't it need to close the fd as well?

the stdOut handle gets used when reading the command output (using hGetContents)
- doesn't the handle need to get closed? or will this happen
automatically if hGetContents finds EOF ?
- and also here, shouldn't the fd get closed?

More general:
what happens when closing a handle when there's still output left?
Will reading further output throw an exception or just think it's EOF?
And what happens when closing the underlying FD? will the handle
"break"? or will it close automatically?

Thanks for any help
Mathijs


More information about the Haskell-Cafe mailing list