patch applied (packages/base): FIX part of #2301
simonmarhaskell at gmail.com
Wed Jul 9 05:51:55 EDT 2008
Wed Jul 9 02:44:37 PDT 2008 Simon Marlow <marlowsd at gmail.com>
* FIX part of #2301
Control-C now causes the new exception (AsyncException UserInterrupt)
to be raised in the main thread. The signal handler is set up by
GHC.TopHandler.runMainIO, and can be overriden in the usual way by
installing a new signal handler. The advantage is that now all
programs will get a chance to clean up on ^C.
When UserInterrupt is caught by the topmost handler, we now exit the
program via kill(getpid(),SIGINT), which tells the parent process that
we exited as a result of ^C, so the parent can take appropriate action
(it might want to exit too, for example).
One subtlety is that we have to use a weak reference to the ThreadId
for the main thread, so that the signal handler doesn't prevent the
main thread from being subject to deadlock detection.
M ./GHC/IOBase.lhs +4
M ./GHC/TopHandler.lhs -3 +77
View patch online:
More information about the Cvs-libraries