replacement for popen
uwe at fh-wedel.de
Wed Apr 13 02:53:18 EDT 2005
Simon Marlow wrote:
> If you really must use hGetContents, then the hack above is necessary:
> you have to force the output strings before waiting for the process to
> terminate. This would be slightly cleaner:
> > res <- hGetContents outH
> > errs <- hGetContents errH
> > forkIO (evaluate (length res))
> > forkIO (evaluate (length errs))
> which avoids blocking the main thread, but ensures that all the data
> gets pulled as it becomes available.
> forkIO(evaluate(length res))
the types do not match. evaluate has result IO Int
but forkIO expects IO ().
> forkIO(evaluate(length res) >> return ())
but this version again blocks.
More information about the Libraries