#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#if USE_PAPI
#include "Papi.h"
return;
}
-#if defined(DEBUG)
- /* Start off by initialising the allocator debugging so we can
- * use it anywhere */
- initAllocator();
-#endif
+ /* Initialise the stats department, phase 0 */
+ initStats0();
/* Next we do is grab the start time...just in case we're
* collecting timing statistics.
*/
stat_startInit();
+#if defined(DEBUG)
+ /* Start off by initialising the allocator debugging so we can
+ * use it anywhere */
+ initAllocator();
+#endif
+
#ifdef PAR
/*
* The parallel system needs to be initialised and synchronised before
setProgArgv(*argc,*argv);
}
+ /* Initialise the stats department, phase 1 */
+ initStats1();
+
#ifdef USE_PAPI
papi_init();
#endif
initTimer();
startTimer();
- /* Initialise the stats department */
- initStats();
-
#if defined(RTS_USER_SIGNALS)
if (RtsFlags.MiscFlags.install_signal_handlers) {
/* Initialise the user signal handler set */
/* start timing the shutdown */
stat_startExit();
+ OnExitHook();
+
#if defined(RTS_USER_SIGNALS)
if (RtsFlags.MiscFlags.install_signal_handlers) {
freeSignalHandlers();
PAR_TICKY_PAR_END();
#endif
+ // uninstall signal handlers
+ resetDefaultHandlers();
+
/* stop timing the shutdown, we're about to print stats */
stat_endExit();
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);
}
}
+#ifndef mingw32_HOST_OS
+void
+shutdownHaskellAndSignal(int sig)
+{
+ hs_exit_(rtsFalse);
+ kill(getpid(),sig);
+}
+#endif
+
/*
* called from STG-land to exit the program
*/