[Haskell-cafe] program execution and laziness

Tim Newsham newsham at lava.net
Wed Sep 13 21:32:24 EDT 2006

I'm having a problem with program execution in win32 which seems
to be tied to laziness.  The function I'm using is:

runCmd cmd outdir dir base ext = do
     let argv = words cmd
     (i,o,e,p) <- runInteractiveProcess (head argv) (drop 1 argv) Nothing 
     hClose i
     out <- hGetContents o
     -- print out
     x <- waitForProcess p
     hClose o
     hClose e
     case x of
         ExitSuccess      -> return 0
         (ExitFailure n)  -> return n

this is hanging indefinitely when I run it in win32.  If I add
in the print statement (commented out above) it works fine!  So
I can only imagine that waitForProcess is hanging when I haven't
drained the stdout stream.

How can I force hGetContents to be strict (or at least to completely
process the stream prior to the waitForProcess command)?

Tim Newsham

More information about the Haskell-Cafe mailing list