Make sure stdoutGateway is flushed before exiting.

This commit is contained in:
Daniel Gröber
2015-09-14 09:44:16 +02:00
parent 56902bfe2d
commit 5b02cc1bb0
3 changed files with 48 additions and 23 deletions

View File

@@ -47,7 +47,7 @@ import Control.Monad.Reader (runReaderT)
import Control.Monad.State.Strict (runStateT)
import Control.Monad.Trans.Journal (runJournalT)
import Exception (ExceptionMonad(..))
import Exception
import System.Directory
import Prelude
@@ -82,9 +82,9 @@ runGmOutT opts ma = do
runGmOutT' gmo ma
runGmOutT' :: IOish m => GhcModOut -> GmOutT m a -> m a
runGmOutT' gmo ma = do
gbracket_ (liftIO $ forkIO $ stdoutGateway $ gmoChan gmo)
(liftIO . killThread)
runGmOutT' gmo@(gmoChan -> chan) ma = do
gbracket_ (liftIO $ forkIO $ stdoutGateway chan)
(const $ liftIO $ flushStdoutGateway chan)
(flip runReaderT gmo $ unGmOutT ma)
-- | Run a @GhcModT m@ computation.