summaryrefslogtreecommitdiff
path: root/rts/RtsSignals.h
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-07-09 08:49:16 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-07-09 08:49:16 +0000
commitaddff19a9c6ee89e36cb966988aa9f868ae2e4a6 (patch)
tree8c1e44ba372c452aa284170f8aa22b265040efa3 /rts/RtsSignals.h
parent5f923aab146d892f019ff1c1627edf20378a3aac (diff)
downloadhaskell-addff19a9c6ee89e36cb966988aa9f868ae2e4a6.tar.gz
FIX part of #2301, and #1619
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. 1619: we now ignore SIGPIPE by default. Although POSIX says that a SIGPIPE should terminate the process by default, I wonder if this decision was made because many C applications failed to check the exit code from write(). In Haskell a failed write due to a closed pipe will generate an exception anyway, so the main difference is that we now get a useful error message instead of silent program termination. See #1619 for more discussion.
Diffstat (limited to 'rts/RtsSignals.h')
-rw-r--r--rts/RtsSignals.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/rts/RtsSignals.h b/rts/RtsSignals.h
index 721561e5b6..77f22249b2 100644
--- a/rts/RtsSignals.h
+++ b/rts/RtsSignals.h
@@ -40,6 +40,7 @@ extern void initUserSignals(void);
* Ctrl+C handler that shuts down the RTS in an orderly manner.
*/
extern void initDefaultHandlers(void);
+extern void resetDefaultHandlers(void);
extern void freeSignalHandlers(void);