
Hello, As far as I can tell, createProcess is closing the handle: createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) createProcess cp = do r <- runGenProcess_ "runGenProcess" cp Nothing Nothing maybeCloseStd (std_in cp) maybeCloseStd (std_out cp) maybeCloseStd (std_err cp) return r where maybeCloseStd :: StdStream -> IO () maybeCloseStd (UseHandle hdl) | hdl /= stdin && hdl /= stdout && hdl /= stderr = hClose hdl maybeCloseStd _ = return () I don't see a way around it. - jeremy At Fri, 13 Feb 2009 15:38:32 +0000, Neil Mitchell wrote:
Hi,
I want to run multiple programs and dump the stdout/stderr to a file, I've tried doing:
h <- openFile file WriteMode let c = CreateProcess (RawCommand file []) Nothing Nothing Inherit (UseHandle h) (UseHandle h) False (_,_,_,pid) <- createProcess c waitForProcess pid hPutStrLn h "Test"
But by the time I get to the hPutStrLn line it says:
Main: test.log: hPutStr: illegal operation (handle is closed)
What have I done wrong? Did createProcess close the handle, and is there a way round this? This is using GHC 6.10 on Windows with the new process-1.0.1.1
Thanks
Neil _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe