@@ -8,9 +8,9 @@ module Test.DocTest.Internal.Runner where
88import Prelude hiding (putStr , putStrLn , error )
99
1010import Control.Concurrent (Chan , writeChan , readChan , newChan , forkIO , ThreadId , myThreadId , MVar , newMVar )
11- import Control.Exception (SomeException )
11+ import Control.Exception (SomeException , AsyncException , throw )
1212import Control.Monad hiding (forM_ )
13- import Control.Monad.Catch (catch )
13+ import Control.Monad.Catch (catches , Handler ( Handler ) )
1414import Data.Foldable (forM_ )
1515import Data.Function (on )
1616import Data.List (sortBy )
@@ -323,9 +323,16 @@ makeThreadPool nThreads parseArgs mutator = do
323323 forkIO $ withGhc parseArgs $ forever $ do
324324 modName <- liftIO $ readChan input
325325 threadId <- liftIO myThreadId
326- catch
326+ let update e = liftIO $ writeChan output (threadId, UpdateInternalError modName e)
327+ catches
327328 (mutator output modName)
328- (\ e -> liftIO $ writeChan output (threadId, UpdateInternalError modName e))
329+ -- Re-throw AsyncException, otherwise execution will not terminate on
330+ -- SIGINT (ctrl-c). All AsyncExceptions are re-thrown (not just
331+ -- UserInterrupt) because all of them indicate severe conditions and
332+ -- should not occur during normal operation.
333+ [ Handler (\ e -> throw (e :: AsyncException ))
334+ , Handler (\ e -> update (e :: SomeException ))
335+ ]
329336 return (input, output)
330337
331338reportModuleParsed :: (? verbosity :: LogLevel , ? threadId :: ThreadId ) => ModuleName -> Int -> Report ()
0 commit comments