[Haskell-cafe] system in forkIO

Don Stewart dons at galois.com
Sun Sep 14 17:52:28 EDT 2008


marcot:
> Em Dom, 2008-09-14 às 16:07 -0300, Marco Túlio Gontijo e Silva escreveu:
> > Thanks, I got it to work running 
> > 
> > threadWaitRead stdInput
> > 
> > before getChar.
> 
> Now I've got another problem:
> 
> > import Control.Concurrent
> > import System.IO
> > import System.Process
> 
> > main :: IO ()
> > main
> >   = do
> >     process <- runCommand "wget
> http://ftp.br.debian.org/debian/pool/main/g/ghc6/ghc6_6.8.2-6_amd64.deb"
> >     forkIO
> >       $ putStrLn "fork"
> >       >> getChar >>= putChar
> >       >> terminateProcess process
> >     waitForProcess process
> >     return ()
> 
> Not even fork is shown.  Any hints?

Daemonic threads. When the main thread exits, everything exits. Check
the docs for Control.Concurrent.

You better use an MVar to ensure the main thread waits on its child.

-- Don


More information about the Haskell-Cafe mailing list