当我使用Haskell createProcess时,我需要fork之前好像我在c中使用exec吗?
从我已经看到的示例和我已经尝试的我不认为我做但如果我从输出句柄读取一旦我得到预期的结果但如果我尝试阅读两次它甚至不读一次.
例如:
beginProcess与createProcess相同,z3是从stdin读取并写入stdout的smt解算器.
execute :: Process -> String -> IO String
execute (Just std_in, Just std_out,_,_) cmd = do
hPutStr std_in cmd
hFlush std_in
hGetLine std_out
main :: IO()
main = do
proc <- beginProcess "z3" ["-smt2","-in"]
execute proc "(set-option :print-success true)" >>= print
execute proc "(set-option :print-success true)" >>= print
Run Code Online (Sandbox Code Playgroud)
如果我执行一个我得到预期的结果,但如果我这样做都没有任何反应.我在读取或写错了句柄吗?
感谢您提供任何帮助.