[Haskell-cafe] Re: [Haskell] A simple server (or how to do io).

Einar Karttunen ekarttun at cs.helsinki.fi
Wed Dec 21 09:12:38 EST 2005

On 21.12 01:13, Pupeno wrote:
> So, I install a signal handler with installHandler... and then ? how do I 
> prevent the program for quiting ? am I missing some kind of event loop here ?

Here is a small server program:

main = performForkWithUnixySessionStuff work

-- this is just for testing, replace with real implementation
performForkWithUnixySessionStuff x = x

work = do s1 <- runStreamServer ...
          s2 <- runDgramServer ...
          mv <- newEmptyMVar
          installHandler someSignal (Catch (putMVar mv ())) Nothing
          takeMVar mv
          killServer s1
          killServer s2

For simple testing you might want to just use getLine to wait for the right
time to exit.

- Einar Karttunen

More information about the Haskell-Cafe mailing list