X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FSignals.c;h=4ae22cd143bc416d59a3074329554ca1eda19e85;hb=afb01c35a0a4f1525070b0458fa186a12e62240a;hp=5f5f77fd39fd6d40b1b7b5894ab7e7c0026a32c6;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index 5f5f77f..4ae22cd 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -16,6 +16,8 @@ #include "posix/Signals.h" #include "RtsUtils.h" #include "RtsFlags.h" +#include "Prelude.h" +#include "ThrIOManager.h" #ifdef alpha_HOST_ARCH # if defined(linux_HOST_OS) @@ -107,6 +109,9 @@ more_handlers(I_ sig) // Here's the pipe into which we will send our signals static int io_manager_pipe = -1; +#define IO_MANAGER_WAKEUP 0xff +#define IO_MANAGER_DIE 0xfe + void setIOManagerPipe (int fd) { @@ -115,6 +120,40 @@ setIOManagerPipe (int fd) io_manager_pipe = fd; } +#if defined(THREADED_RTS) +void +ioManagerWakeup (void) +{ + // Wake up the IO Manager thread by sending a byte down its pipe + if (io_manager_pipe >= 0) { + StgWord8 byte = (StgWord8)IO_MANAGER_WAKEUP; + write(io_manager_pipe, &byte, 1); + } +} + +void +ioManagerDie (void) +{ + // Ask the IO Manager thread to exit + if (io_manager_pipe >= 0) { + StgWord8 byte = (StgWord8)IO_MANAGER_DIE; + write(io_manager_pipe, &byte, 1); + } +} + +void +ioManagerStart (void) +{ + // Make sure the IO manager thread is running + Capability *cap; + if (io_manager_pipe < 0) { + cap = rts_lock(); + rts_evalIO(cap,&base_GHCziConc_ensureIOManagerIsRunning_closure,NULL); + rts_unlock(cap); + } +} +#endif + #if !defined(THREADED_RTS) #define N_PENDING_HANDLERS 16 @@ -468,7 +507,7 @@ initDefaultHandlers() sigemptyset(&action.sa_mask); action.sa_flags = 0; if (sigaction(SIGINT, &action, &oact) != 0) { - errorBelch("warning: failed to install SIGINT handler"); + sysErrorBelch("warning: failed to install SIGINT handler"); } #if defined(HAVE_SIGINTERRUPT) @@ -480,7 +519,7 @@ initDefaultHandlers() sigemptyset(&action.sa_mask); action.sa_flags = 0; if (sigaction(SIGCONT, &action, &oact) != 0) { - errorBelch("warning: failed to install SIGCONT handler"); + sysErrorBelch("warning: failed to install SIGCONT handler"); } // install the SIGFPE handler @@ -498,7 +537,7 @@ initDefaultHandlers() sigemptyset(&action.sa_mask); action.sa_flags = 0; if (sigaction(SIGFPE, &action, &oact) != 0) { - errorBelch("warning: failed to install SIGFPE handler"); + sysErrorBelch("warning: failed to install SIGFPE handler"); } #endif @@ -507,4 +546,11 @@ initDefaultHandlers() #endif } +void +freeSignalHandlers(void) { + if (signal_handlers != NULL) { + stgFree(signal_handlers); + } +} + #endif /* RTS_USER_SIGNALS */