diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-11-07 15:24:00 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-11-08 13:25:33 +0000 |
commit | 2babc2a527533a67a59cb62782e80292f689fa10 (patch) | |
tree | fac47b8dd259cacb2f71da2d57d7a2c31077d4b3 /rts/RtsStartup.c | |
parent | 81e29e42d6eea1f1e54cbec698aa1fdf3c6fb7f7 (diff) | |
download | haskell-2babc2a527533a67a59cb62782e80292f689fa10.tar.gz |
Flush stdout and stderr during hs_exit() (#5594)
Ensures that these handles are flushed even when the RTS is being used
as a library, with no main.
Needs a corresponding change to libraries/base.
Diffstat (limited to 'rts/RtsStartup.c')
-rw-r--r-- | rts/RtsStartup.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index dc6214357a..6e803bba24 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -69,6 +69,8 @@ void exitLinker( void ); // there is no Linker.h file to include // Count of how many outstanding hs_init()s there have been. static int hs_init_count = 0; +static void flushStdHandles(void); + /* ----------------------------------------------------------------------------- Initialise floating point unit on x86 (currently disabled; See Note [x86 Floating point precision] in compiler/nativeGen/X86/Instr.hs) @@ -296,6 +298,8 @@ hs_exit_(rtsBool wait_foreign) OnExitHook(); + flushStdHandles(); + // sanity check #if defined(DEBUG) checkFPUStack(); @@ -407,6 +411,17 @@ hs_exit_(rtsBool wait_foreign) freeRtsArgs(); } +// Flush stdout and stderr. We do this during shutdown so that it +// happens even when the RTS is being used as a library, without a +// main (#5594) +static void flushStdHandles(void) +{ + Capability *cap; + cap = rts_lock(); + rts_evalIO(cap, &base_GHCziTopHandler_flushStdHandles_closure, NULL); + rts_unlock(cap); +} + // The real hs_exit(): void hs_exit(void) |