[project @ 1999-09-22 11:53:33 by sof]
[ghc-hetmet.git] / ghc / rts / RtsStartup.c
index 1c50c08..7b91e40 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.16 1999/07/03 18:39:40 sof Exp $
+ * $Id: RtsStartup.c,v 1.21 1999/09/22 11:53:33 sof Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
 #include "StablePriv.h" /* initStablePtrTable */
 #include "Schedule.h"   /* initScheduler */
 #include "Stats.h"      /* initStats */
+#include "Signals.h"
+#include "Itimer.h"
 #include "Weak.h"
 #include "Ticky.h"
 
 #if defined(PROFILING)
 # include "ProfRts.h"
-#elif defined(DEBUG)
-# include "DebugProf.h"
+# include "ProfHeap.h"
 #endif
 
 #ifdef PAR
@@ -110,14 +111,21 @@ startupHaskell(int argc, char *argv[])
     initProfiling();
 #endif
 
+    /* start the ticker */
+    install_vtalrm_handler();
+    initialize_virtual_timer(TICK_MILLISECS);
+
     /* Initialise the scheduler */
     initScheduler();
 
     /* Initialise the stats department */
     initStats();
 
-#if 0
+#if !defined(mingw32_TARGET_OS) && !defined(PAR)
+    /* Initialise the user signal handler set */
     initUserSignals();
+    /* Set up handler to run on SIGINT */
+    init_shutdown_handler();
 #endif
  
     /* When the RTS and Prelude live in separate DLLs,
@@ -148,6 +156,7 @@ startupHaskell(int argc, char *argv[])
 void
 shutdownHaskellAndExit(int n)
 {
+  OnExitHook();
   shutdownHaskell();
   stg_exit(n);
 }
@@ -170,6 +179,9 @@ shutdownHaskell(void)
   /* clean up things from the storage manager's point of view */
   exitStorage();
 
+  /* stop the ticker */
+  initialize_virtual_timer(0);
+  
 #if defined(PROFILING) || defined(DEBUG)
   endProfiling();
 #endif
@@ -187,7 +199,7 @@ shutdownHaskell(void)
 
 
 /* 
- * called from STG-land to exit the program cleanly 
+ * called from STG-land to exit the program
  */
 
 void  
@@ -196,7 +208,7 @@ stg_exit(I_ n)
 #ifdef PAR
   par_exit(n);
 #else
-  OnExitHook();
   exit(n);
 #endif
 }
+