Are handles closed automatically when they fall out of scope?

Peter Simons simons at
Fri Oct 22 16:57:51 EDT 2004

I know it's a rather mundane question, but I couldn't find
an answer to it!

So what does happen when I forget to hClose a Handle? Will
the garbage collector do that for me? Or not?

And more specifically, what about the handles
runInteractiveProcess returns? Do I have to close the
"stdin" Handle? All of them? What happens when I use
terminateProcess? Do I have to hClose them nonetheless?

And while I am at it: How about Socket? Do I have to sClose
a socket I obtained from listenOn or accept?

Any definite answers would be highly appreciated. 


More information about the Glasgow-haskell-users mailing list