[Haskell-cafe] Can't figure out source of race condition when using System.Process

Bryan O'Sullivan bos at serpentine.com
Sun Nov 2 12:58:47 EST 2008

2008/11/2 Rafal Kolanski <xs at xaph.net>

> Unfortunately, it also segfaults once in a while, probably indicating I
> have some kind of race condition ... but I can't figure out why.

What is the "it" that segfaults? The Haskell program shouldn't, at least.

That said, your code for reading from child processes is wrong. You should
read all of a child's output strictly (i.e. hGetContents alone will not do
the trick) before you wait for its exit status. Your current scheme reverses
this order, and there is hence no guarantee that it will read anything from
the defunct child process. There's some possibility that this might be the
cause of your segfault, which to me would suggest the presence of a bug in
the runtime system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081102/4c0679e7/attachment.htm

More information about the Haskell-Cafe mailing list