how to catch GHC "no threads to run" exception?

paul@theV.net paul@theV.net
Thu, 1 Aug 2002 16:39:23 +0800


My program runs 3 threads, and after a few minutes' execution
all threads come to a state that they all wait on some MVars,
then the program halts with an error:

test: no threads to run:  infinite loop or deadlock?

(test is my program name)

My problem is that this behavior is actually desired, but
how do I catch this exception and do some bookkeeping
(closing external IO, etc.) and then a proper exit?

Thanks in advance!

Regards,
.paul.