X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FSignals.c;h=09dacbeb11933c3d15a6aa98f52ddc4fadb39949;hb=8f52645bd99ee3e636a34826c0cbfc5939920da1;hp=fcfa1f121453b08fa864b383ffac92b8a6590618;hpb=33b42ef9c0d3b05ad889959bb1d143ae9ffe1665;p=ghc-hetmet.git diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index fcfa1f1..09dacbe 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -226,14 +226,14 @@ generic_handler(int sig) stg_exit(EXIT_FAILURE); } + MainCapability.context_switch = 1; + #endif /* THREADED_RTS */ // re-establish the signal handler, and carry on sigemptyset(&signals); sigaddset(&signals, sig); sigprocmask(SIG_UNBLOCK, &signals, NULL); - - context_switch = 1; } /* ----------------------------------------------------------------------------- @@ -496,6 +496,33 @@ initDefaultHandlers(void) #ifdef alpha_HOST_ARCH ieee_set_fp_control(0); #endif + + // ignore SIGPIPE; see #1619 + action.sa_handler = SIG_IGN; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + if (sigaction(SIGPIPE, &action, &oact) != 0) { + sysErrorBelch("warning: failed to install SIGPIPE handler"); + } +} + +void +resetDefaultHandlers(void) +{ + struct sigaction action; + + action.sa_handler = SIG_DFL; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + + // restore SIGINT + if (sigaction(SIGINT, &action, NULL) != 0) { + sysErrorBelch("warning: failed to uninstall SIGINT handler"); + } + // restore SIGPIPE + if (sigaction(SIGPIPE, &action, NULL) != 0) { + sysErrorBelch("warning: failed to uninstall SIGPIPE handler"); + } } void