[Haskell-cafe] createProcess shutting file handles

Neil Mitchell ndmitchell at gmail.com
Fri Feb 13 10:38:32 EST 2009


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


More information about the Haskell-Cafe mailing list