summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-04-06 14:48:36 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-04-06 14:48:36 +0000
commit1494f895d69a33df2f8d855f73943faec5c6858e (patch)
tree7932743cbeaa37105bcd9b5746c4def06fa5a03c
parentd7d596d039b48dec6b71df9c4bca0d12958ecdb9 (diff)
downloadhaskell-1494f895d69a33df2f8d855f73943faec5c6858e.tar.gz
Add SA_RESTART flag to the timer signal handler.
This seems to be necessary to prevent readline being confused by our SIGALRM handler.
-rw-r--r--ghc/rts/posix/Itimer.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ghc/rts/posix/Itimer.c b/ghc/rts/posix/Itimer.c
index 06d0e6c82a..83ed84d6ef 100644
--- a/ghc/rts/posix/Itimer.c
+++ b/ghc/rts/posix/Itimer.c
@@ -84,7 +84,18 @@ install_vtalrm_handler(TickProc handle_tick)
action.sa_handler = handle_tick;
sigemptyset(&action.sa_mask);
+
+#ifdef SA_RESTART
+ // specify SA_RESTART. One consequence if we don't do this is
+ // that readline gets confused by the -threaded RTS. It seems
+ // that if a SIGALRM handler is installed without SA_RESTART,
+ // readline installs its own SIGALRM signal handler (see
+ // readline's signals.c), and this somehow causes readline to go
+ // wrong when the input exceeds a single line (try it).
+ action.sa_flags = SA_RESTART;
+#else
action.sa_flags = 0;
+#endif
return sigaction(ITIMER_SIGNAL, &action, NULL);
}