[Haskell-cafe] Re: Cleaning up threads

Ben Millwood haskell at benmachine.co.uk
Tue Sep 14 19:11:07 EDT 2010

On Tue, Sep 14, 2010 at 9:44 PM, Mitar <mmitar at gmail.com> wrote:
> Hi!
> On Tue, Sep 14, 2010 at 9:04 PM, Gregory Collins
> <greg at gregorycollins.net> wrote:
>> That's surprising to me -- this is how we kill the Snap webserver
>> (killThread the controlling thread...).
> Yes. This does work. The only problem is that my main thread then
> kills child threads, which then start killing main thread again, which
> then again kills child threads and interrupt cleanup.

This sounds wrong. Why is the main thread sending more than one kill?
Handlers for some exception shouldn't run more than once unless you
set them up that way.

Are you perhaps being tripped up by the issue whereby when the main
thread dies, the RTS just shuts down even if other threads are
running? You might find you need some kind of maybe MVar-driven
mechanism to keep the main thread alive until all else is definitely

Maybe this behaviour should be considered a bug, I don't know. It
would be nice if after a forkIO threads were effectively equal.

More information about the Haskell-Cafe mailing list