#534 Problem with Threading under GHC

open
nobody
GHCi (16)
5
2005-11-10
2005-11-10
Marco Block
No

hi ghc-friends,

i try the following code, but it don't work:

import System.Process
import Control.Concurrent
import System.IO
p = threadDelay 10000000
main3 = do putStrLn "test"
hClose stdin
(inp, out, err, pid) <-
runInteractiveProcess "Test.exe" [] Nothing Nothing
p
forkIO (putStrLn =<<
hGetContents out)
forkIO (putStrLn =<<
hGetContents err)
p
putStrLn "inp"
forkIO (hPutStrLn inp "in" >>
hClose
inp)
p
forkIO (putStrLn =<<
hGetContents out)
forkIO (putStrLn =<<
hGetContents err)
putStrLn "out"
threadDelay 1000000
forkIO (hPutStrLn inp "quit" >>
hClose
inp)
hShow out
return ()

thanks for helping.

Discussion

  • Simon Marlow
    Simon Marlow
    2005-11-10

    Logged In: YES
    user_id=48280

    Please could you give more information: we don't know what
    "Test.exe" is. What do you expect to happen, and what in
    fact does happen? What behaviour are you claiming is at fault?

     
  • Marco Block
    Marco Block
    2005-12-21

    Logged In: YES
    user_id=1376599

    Sorry ... we working on so many problems and now it's
    time for the GHC-Answer :).

    Ok, we have one executable program we wants to start and
    after the start we give him one parameter which is a string.
    The executable file is a chess engine.

    Communication is like:
    "e2e4"

    then we waiting for response ...
    and the engine sais:
    "c7c5"

    this is our thread. But the code doesn't work. The
    engine was started but not the communication.

    thanks alot.