[Haskell-cafe] trying to understand runProcess handles

Donn Cave donn at drizzle.com
Fri Mar 3 13:57:11 EST 2006

On Fri, 3 Mar 2006, Matthias Fischmann wrote:
>> ... but as long as you're making a pipe for
>> error output, you may as well read it and see if gnuplot has left
>> any clue to its problem there.
> that doesn't work -- all the handles are closed at least after the
> process has died.  hard to tell whether the process dying caused the
> handles to close or whether the handles were closed already by then.

Process exit closes the process' end of the pipes, but can't
do anything to the other end.  When it closes the write end,
a read on the other end returns with end of file.  The same
pipe file descriptor may be inherited by multiple processes,
any one of which may hold it open - only the last close matters.
That's why functions like runProcess normally close the opposite
ends of the pipe, in the parent & child forks, so that the parent
doesn't hold the child's open or vice versa.

	Donn Cave, donn at drizzle.com

More information about the Haskell-Cafe mailing list