X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=f221ad8b13b34b813d3a09c57c9384a09511a8cb;hb=bbc583766a08678d03740354bed216e268306356;hp=c55fdfb537c5007678946e6cd0935da0d66bca8b;hpb=1663532f26ae2e68f04d067b11bd177d307637b1;p=ghc-hetmet.git diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index c55fdfb..f221ad8 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -71,6 +71,9 @@ #ifdef HAVE_SIGNAL_H #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif #if USE_PAPI #include "Papi.h" @@ -383,6 +386,8 @@ hs_exit_(rtsBool wait_foreign) /* start timing the shutdown */ stat_startExit(); + OnExitHook(); + #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { freeSignalHandlers(); @@ -440,6 +445,9 @@ hs_exit_(rtsBool wait_foreign) PAR_TICKY_PAR_END(); #endif + // uninstall signal handlers + resetDefaultHandlers(); + /* stop timing the shutdown, we're about to print stats */ stat_endExit(); @@ -528,10 +536,10 @@ shutdownHaskell(void) void shutdownHaskellAndExit(int n) { - if (hs_init_count == 1) { - OnExitHook(); - hs_exit_(rtsFalse); - // we're about to exit(), no need to wait for foreign calls to return. + // we're about to exit(), no need to wait for foreign calls to return. + hs_exit_(rtsFalse); + + if (hs_init_count == 0) { #if defined(PAR) /* really exit (stg_exit() would call shutdownParallelSystem() again) */ exit(n); @@ -541,6 +549,15 @@ shutdownHaskellAndExit(int n) } } +#ifndef mingw32_HOST_OS +void +shutdownHaskellAndSignal(int sig) +{ + hs_exit_(rtsFalse); + kill(getpid(),sig); +} +#endif + /* * called from STG-land to exit the program */