Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/d18b5d53e74318e4a6bc2ad0557ff71a00c1abe1 >--------------------------------------------------------------- commit d18b5d53e74318e4a6bc2ad0557ff71a00c1abe1 Author: Simon Marlow <[email protected]> Date: Fri Aug 12 14:26:34 2011 +0100 make shutdownHaskellAndExit() shut down the RTS and exit immediately (#5402) >--------------------------------------------------------------- includes/RtsAPI.h | 6 +++++- rts/RtsMain.c | 2 +- rts/RtsMain.h | 3 ++- rts/RtsStartup.c | 8 +++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h index 1444dbc..dc151fa 100644 --- a/includes/RtsAPI.h +++ b/includes/RtsAPI.h @@ -43,7 +43,11 @@ typedef struct Capability_ Capability; extern void startupHaskell ( int argc, char *argv[], void (*init_root)(void) ); extern void shutdownHaskell ( void ); -extern void shutdownHaskellAndExit ( int exitCode ); +extern void shutdownHaskellAndExit ( int exitCode ) +#if __GNUC__ >= 3 + __attribute__((__noreturn__)) +#endif + ; extern void getProgArgv ( int *argc, char **argv[] ); extern void setProgArgv ( int argc, char *argv[] ); extern void getFullProgArgv ( int *argc, char **argv[] ); diff --git a/rts/RtsMain.c b/rts/RtsMain.c index 0ed6df4..a822da9 100644 --- a/rts/RtsMain.c +++ b/rts/RtsMain.c @@ -38,6 +38,7 @@ static StgClosure *progmain_closure; /* This will be ZCMain_main_closure */ * INTERPRETER is set */ #ifndef INTERPRETER /* Hack */ +static void real_main(void) GNUC3_ATTRIBUTE(__noreturn__); static void real_main(void) { int exit_status; @@ -112,6 +113,5 @@ int hs_main(int argc, char *argv[], StgClosure *main_closure) #if defined(mingw32_HOST_OS) END_CATCH #endif - return 0; /* not reached, but keeps gcc -Wall happy */ } # endif /* BATCH_MODE */ diff --git a/rts/RtsMain.h b/rts/RtsMain.h index 24e5819..e004480 100644 --- a/rts/RtsMain.h +++ b/rts/RtsMain.h @@ -13,6 +13,7 @@ * The entry point for Haskell programs that use a Haskell main function * -------------------------------------------------------------------------- */ -int hs_main(int argc, char *argv[], StgClosure *main_closure); +int hs_main(int argc, char *argv[], StgClosure *main_closure) + GNUC3_ATTRIBUTE(__noreturn__); #endif /* RTSMAIN_H */ diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index c115701..6e18fba 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -424,12 +424,14 @@ shutdownHaskell(void) void shutdownHaskellAndExit(int n) { + // even if hs_init_count > 1, we still want to shut down the RTS + // and exit immediately (see #5402) + hs_init_count = 1; + // we're about to exit(), no need to wait for foreign calls to return. hs_exit_(rtsFalse); - if (hs_init_count == 0) { - stg_exit(n); - } + stg_exit(n); } #ifndef mingw32_HOST_OS _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
