
Hi everyone!
I run into a problem with readProcessWithExitCode (from System.Process
module). Basically what i want is to start an exe file, giving it some
input on stdin and receiving the results on stdout. But id the stdin and
out is bigger that 5000-7000 char (nondeterministically), i get
commitAndReleaseBuffer exception and sometimes hFlush exception. I'm
getting these errors with GHCi 6.12.3, if it matters.
Have you guys any idea what causes the problem, to how to avoid it?
Thanks
Daniel
Here is a dummy example, which produces the exception:
Haskell code:
import System.Process
test = do
result <- sequence $ Prelude.map (\x -> runOnce x) [1..10000]
return ()
where
runOnce :: Int -> IO [Int]
runOnce i = do
putStrLn (show i)
a <- caller i
b <- caller i
return (a++b)
caller a = do
(exit_code,stdout) <- readProcessWithExitCode "a.exe" [show a]
(unlines (map show [1..850]))
return (read stdout)
C code (for executable)
#include

Hello Leskó, Friday, October 22, 2010, 1:50:54 AM, you wrote:
I run into a problem with readProcessWithExitCode (from System.Process module). Basically what i want is to start an exe file, giving it some input on stdin and receiving the results on stdout. But id the stdin and
look for other functions in the library. one that you need should read and write data simultaneously, for example by using separate thread -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (2)
-
Bulat Ziganshin
-
Leskó Dániel