FIX part of #2301
authorSimon Marlow <marlowsd@gmail.com>
Wed, 9 Jul 2008 09:44:37 +0000 (09:44 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 9 Jul 2008 09:44:37 +0000 (09:44 +0000)
commit16a3c4090efd35dc6e85da48f9ab9711a51cf0e7
tree1181e118d4704f04cdfa31a68543504074251944
parente8d0c7d30e8fbf89113e661e7ede45dd5832c6e4
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.
GHC/IOBase.lhs
GHC/TopHandler.lhs