diff options
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) |