Concurrent and Posix libraries...
Marcus Shawcroft
marcus@thepub.demon.co.uk
Wed, 19 Dec 2001 23:00:58 +0000
Hi,
I want to use a thread in concurrent haskell to manage a posix
fork/exec/wait. I expected the test code attached below to output
"recovering result" once, instead I get "recovering result" twice. Can
anyone shed some light on whats going wrong?
(ghci 5.02.1 x86 linux)
Thanks
/Marcus
> module Test where
> import Concurrent
> import Posix
> main = do
> mv <- newEmptyMVar
> forkIO $ do x <- forkProcess
> case x of
> Nothing -> do
> executeFile "sleep" True ["2"] Nothing
> error "oops"
> Just pid ->
> getProcessStatus True False pid
> putMVar mv ()
> print "recovering result"
> takeMVar mv