Re: [Haskell-cafe] readProcess exception

2010-10-22 Thread Bulat Ziganshin
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,
 Bulatmailto:bulat.zigans...@gmail.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] readProcess exception

2010-10-21 Thread Leskó Dániel

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..1]
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 stdio.h
#include complex.h
#include stdlib.h


int main(int argc, char *argv[])
{

printf([%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d],100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 

100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 

100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 

100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 

100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 

100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100, 


100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100);

}
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe