On Mar 8, 2010, at 14:26 , Mathijs Kwik wrote:
it writes to the stdIn handle and closes it afterwards.
- doesn't it need to close the fd as well?

Once you've made a Handle from it, the Handle "owns" it; in particular, when the Handle is finalized it will close the fd. Also, attempting to use the fd for anything directly is likely to cause severe confusion to the process or file on the other end.

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 ?

hGetContents automatically closes the Handle lazily.

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?

If you manually close the fd, the Handle will become unhappy and throw an exception. Don't touch an fd after performing an fdToHandle, or a Handle after performing a handleToFd (unless you are very certain about what you're doing, which is likely to require knowledge of how the GHC runtime's Handles work).

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to