Signals + minimal proposal (was Re: asynchronous exceptions)
john at repetae.net
Fri Apr 7 08:06:17 EDT 2006
On Fri, Apr 07, 2006 at 12:36:11PM +0100, Simon Marlow wrote:
> > You should be able to handle the SIGINT imediatly no matter whether
> > foregin code is running if your handler is in its own thread right?
> Yes, but if the signal handler wants to send an exception to the main
> thread, as it often does, and the main thread is in a foreign call, ^C
> appears to not do anything.
This is why I proposed the 'onExit' API, since usually you throw the
signal to the main thread because that is the one that needs to die and
clean up after itself.
but if instead you registered your cleanup functions via 'onExit' then
there would be no need to have 'throwTo' and the exit handler can run
immediatly. no waiting.
in some ways it is nicer than rethrowing the exception because any
thread can register clean-up handlers, not just the main one.
of course, it is only limited to when you actually are quitting the
program, but that isn't so bad for the common case and 'onExit' is very
useful otherwise. (I curse curses for cursing my terminal into it's
occursed state without an exit handler)
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-prime