rethrow exceptions in sandboxIO
authorSimon Marlow <simonmar@microsoft.com>
Thu, 17 May 2007 12:21:47 +0000 (12:21 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 17 May 2007 12:21:47 +0000 (12:21 +0000)
This gives us a chance to catch asynchronous exceptions (e.g. ^C) and break.

compiler/main/InteractiveEval.hs

index f7e9101..c80f293 100644 (file)
@@ -268,10 +268,18 @@ foreign import ccall "&rts_breakpoint_io_action"
 sandboxIO :: MVar Status -> IO [HValue] -> IO Status
 sandboxIO statusMVar thing = 
   withInterruptsSentTo 
-        (forkIO (do res <- Exception.try thing
+        (forkIO (do res <- Exception.try (rethrow thing)
                     putMVar statusMVar (Complete res)))
         (takeMVar statusMVar)
 
+-- | this just re-throws any exceptions received.  The point of this
+-- is that if -fbreak-on-excepsions is on, we only get a chance to break
+-- for synchronous exceptions, and this turns an async exception into
+-- a sync exception, so for instance a ^C exception will break right here
+-- unless it is caught elsewhere.
+rethrow :: IO a -> IO a
+rethrow io = Exception.catch io Exception.throwIO
+
 withInterruptsSentTo :: IO ThreadId -> IO r -> IO r
 withInterruptsSentTo io get_result = do
   ts <- takeMVar interruptTargetThread