Signals + minimal proposal

Simon Marlow simonmar at
Mon Apr 10 10:00:22 EDT 2006

On 09 April 2006 16:02, Marcin 'Qrczak' Kowalczyk wrote:

> "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.

Can a thread be GC'd without being sent an exception first?

How does "cancelling" a thread differ from sending it an exception?


More information about the Haskell-prime mailing list