The problem is that ^C only kills the main thread, but does not kill any child threads that have been spawned.
In happstack the Conf has an optional field where you can supply a ThreadGroup. When threads are forked they will be registered with the ThreadGroup, and when you ^C, all those threads can be killed. That obviously has overhead, so by default we do not use it. But for development in GHCi it can be a huge time saver. http://hackage.haskell.org/packages/archive/happstack-server/7.1.7/doc/html/Happstack-Server-Internal-Types.html#t:Conf Perhaps you can do something similar.. - jeremy On Thu, Apr 11, 2013 at 12:03 AM, Niklas Hambüchen <m...@nh2.me> wrote: > I'm writing a web server app, which I run in ghci: > > :main localhost 8000 > > Unfortunately, after Ctrl-C and :reload, running it again: > > ** Exception: bind: resource busy (Address already in use) > > This is pretty annoying, because quitting-and-restarting takes a lot of > time since I have many dependencies. > > How do you deal with this? Can you propose some working code that can be > wrapped around my main function to make it work? > > My first idea is running main in a separate process. > > If you have a working idea, please also post it as an answer on > http://stackoverflow.com/questions/15890912/how-do-i-terminate-a-socket-server-in-ghci > > Thanks > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe