[Haskell-cafe] system in forkIO
Marco Túlio Gontijo e Silva
marcot at riseup.net
Sun Sep 14 18:19:04 EDT 2008
Em Dom, 2008-09-14 às 14:52 -0700, Don Stewart escreveu:
> > 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.
I don't think this is the problem because the mais thread is not
exiting. wget takes a lot of time to end, and I never really wait it to
finish. I wanted to enable the user to interrupt it, but if it's
finished, I don't want to wait for the user input anymore, so the child
thread can exit with the main one.
I just noticed that if I add a putStrLn "wait" before waitForProcess,
it'll print wait and then fork. I couldn't understand why this
happened, but I can't still pass through getChar to get to
Is it right to call getChar inside a forkIO?
Correio: marcot at riseup.net
XMPP: marcot at jabber.org
IRC: marcot at irc.freenode.net
Rua Turfa, 639/701
Belo Horizonte/MG Brasil
More information about the Haskell-Cafe