On Fre, 2002-03-15 at 12:52, Simon Marlow wrote: > > There's no bug in the libraries: > > The data is read lazily by 'getContents', then you invoke > > 'forkProcess'. > > From this moment on, you should have two (heavy-weight) > > processes competing > > for input from the same source (stdin). > > Thanks Volker. This just strengthens my feeling that lazy I/O is a Very > Bad Thing which should be avoided for non-trivial programs. > Alternatives are: hGetChar, hGetLine, hGetBuf, and hGetArray (the last > one will be in 5.04 and returns an IOUArray of Word8).
OK, if I make the child's child close stdin, after forkProcess, before executeFile, the problem does not occur. But I still don't understand what's going on. The program being called is just /bin/echo, which does not read any input from stdin. I still think there's something wrong. Btw, if it was because of two processes competing for the same input stream, you would have the same problem when reading data "lazily" (chunk by chunk) in a C program. This isn't specific to Haskell's lazy IO. Volker
signature.asc
Description: This is a digitally signed message part