Signals + minimal proposal

Marcin 'Qrczak' Kowalczyk qrczak at
Sun Apr 9 11:02:19 EDT 2006

"Simon Marlow" <simonmar at> writes:

> That sounds hard to program with - surely you want to stop the program
> in order to clean up?  Otherwise the program is going to continue
> working, generating more exit handlers, and we might never get to exit.

Here is how I've done it in Kogut:

An equivalent of Haskell's exitWith simply throws a predefined exception.
When an unhandled exception reaches the toplevel, this exception is
treated specially and is not printed with a stack trace. Exceptions
caused by system signals are special too.

There is a central list of registered exit handlers. On program exit
each handler is run once. Handlers registered during this cleanup are
run too. Any exceptions thrown from handlers are caught and ignored.
This happens after printing a stack trace from an unhandled exception,
just before shutting down the runtime and exiting.

One of exit handlers cancels all other threads (except those which
has been garbage collected) and waits until they finish. New threads
started during this cleanup are canceled too.

   __("<         Marcin Kowalczyk
   \__/       qrczak at

More information about the Haskell-prime mailing list