summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-08-12 14:26:34 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-08-12 17:15:28 +0100
commitd18b5d53e74318e4a6bc2ad0557ff71a00c1abe1 (patch)
tree52619880f0f98d3b13c7f2b8c0edd7e67369cec8
parentfa0406830b8c757ebaf3b0e8a1ca7967f7e0c9c7 (diff)
downloadhaskell-d18b5d53e74318e4a6bc2ad0557ff71a00c1abe1.tar.gz
make shutdownHaskellAndExit() shut down the RTS and exit immediately
(#5402)
-rw-r--r--includes/RtsAPI.h6
-rw-r--r--rts/RtsMain.c2
-rw-r--r--rts/RtsMain.h3
-rw-r--r--rts/RtsStartup.c8
4 files changed, 13 insertions, 6 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index 1444dbc3c5..dc151faf07 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 0ed6df494c..a822da9749 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 24e58199bb..e004480cce 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 c115701d6c..6e18fba273 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