X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=rts%2Fposix%2FSignals.c;h=493b083401c42a4c8313c3cce92f46f6bfa9309e;hb=7fbdd9e0bccec89c958e2a1e36d5ec058fc69a3d;hp=f79e348d601660e299f60c67fe444ace6d327f22;hpb=0e3cc7448cd966c1463adc4685b7d8646dccd0ed;p=ghc-hetmet.git diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index f79e348..493b083 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -148,7 +148,7 @@ ioManagerStart (void) Capability *cap; if (io_manager_pipe < 0) { cap = rts_lock(); - rts_evalIO(cap,&base_GHCziConc_ensureIOManagerIsRunning_closure,NULL); + cap = rts_evalIO(cap,&base_GHCziConc_ensureIOManagerIsRunning_closure,NULL); rts_unlock(cap); } } @@ -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; } /* ----------------------------------------------------------------------------- @@ -458,7 +458,7 @@ shutdown_handler(int sig STG_UNUSED) * doesn't seem to do so. * -------------------------------------------------------------------------- */ void -initDefaultHandlers() +initDefaultHandlers(void) { struct sigaction action,oact; @@ -496,6 +496,33 @@ initDefaultHandlers() #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