summaryrefslogtreecommitdiff
path: root/rts/posix/Signals.c
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-05-01 13:39:23 +0200
committerBen Gamari <ben@smart-cactus.org>2016-05-01 23:29:49 +0200
commit65e13f66c595ad75bd6e9a55496f1372ead2731d (patch)
tree91155c792ab9eda72f24c712e6c4e2641514451f /rts/posix/Signals.c
parent16a51a6c2f265f8670355be03d42b773d93e0684 (diff)
downloadhaskell-65e13f66c595ad75bd6e9a55496f1372ead2731d.tar.gz
rts: Split up Itimer.c
This shouldn't have any functional changes. It merely splits up what are essentially three distinct codepaths which are melding together with CPP. At the moment I merely #include the implementation to use with CPP although this really feels very yucky. Reviewers: erikd, austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2130
Diffstat (limited to 'rts/posix/Signals.c')
-rw-r--r--rts/posix/Signals.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c
index bfc7e82e15..7fb854b894 100644
--- a/rts/posix/Signals.c
+++ b/rts/posix/Signals.c
@@ -14,6 +14,7 @@
#include "Signals.h"
#include "RtsUtils.h"
#include "Prelude.h"
+#include "Ticker.h"
#include "Stable.h"
#include "Libdw.h"
@@ -626,6 +627,34 @@ set_sigtstp_action (rtsBool handle)
}
}
+/* Used by ItimerTimerCreate and ItimerSetitimer implementations */
+void
+install_vtalrm_handler(int sig, TickProc handle_tick)
+{
+ struct sigaction action;
+
+ 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
+
+ if (sigaction(sig, &action, NULL) == -1) {
+ sysErrorBelch("sigaction");
+ stg_exit(EXIT_FAILURE);
+ }
+}
+
/* -----------------------------------------------------------------------------
* Install default signal handlers.
*