1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.13 2000/01/13 12:40:15 simonmar Exp $
4 * (c) The GHC Team 1998-1999
6 * Main function for a standalone Haskell program.
8 * ---------------------------------------------------------------------------*/
10 #define COMPILING_RTS_MAIN
19 #include "Printer.h" /* for printing */
23 #include "Assembler.h"
37 /* Hack: we assume that we're building a batch-mode system unless
40 # ifndef INTERPRETER /* Hack */
41 int main(int argc, char *argv[])
45 SchedulerStatus status;
46 startupHaskell(argc,argv);
49 /* ToDo: want to start with a larger stack size */
50 status = rts_evalIO((StgClosure *)&mainIO_closure, NULL);
52 if (IAmMainThread == rtsTrue) {
53 /*Just to show we're alive */
54 fprintf(stderr, "Main Thread Started ...\n");
56 status = rts_evalIO((StgClosure *)&mainIO_closure, NULL);
58 WaitForPEOp(PP_FINISH,SysManTask);
64 prog_belch("no threads to run: infinite loop or deadlock?");
65 exit_status = EXIT_DEADLOCK;
68 prog_belch("main thread killed");
69 exit_status = EXIT_KILLED;
72 prog_belch("interrupted");
73 exit_status = EXIT_INTERRUPTED;
76 exit_status = EXIT_SUCCESS;
79 barf("main thread completed with no status");
81 shutdownHaskellAndExit(exit_status);
83 # endif /* BATCH_MODE */