[Haskell-cafe] process

h. h._h._h._ at hotmail.com
Thu Feb 22 10:50:36 EST 2007


I need to interact with some other program, and wrote the following code:

module Main where
import System.Process
import System.IO

main :: IO ()
main = do
        putStrLn "Running proc9..."
        (inp,out,err,pid) <- runInteractiveProcess "prog1" [] Nothing Nothing
        hSetBuffering inp LineBuffering
        hSetBuffering out LineBuffering
        hSetBuffering err LineBuffering
        hPutStrLn inp "1"
        a <- hGetLine out
        hPutStrLn inp a
        a <- hGetLine out
        waitForProcess pid
        putStrLn a

But it does not work as I expected. As long as there is no need to put some 
input after having received some output it is no problem, but real interaction 
seems not possible.
Is there a solution to work with the Handles as with stdin,... ?
using ghc 6.6 on Windows

Thanks in advance for your help.

More information about the Haskell-Cafe mailing list