Browse files

Don't remove the thread from interruptTargetThread on ^C (#6116)

  • Loading branch information...
1 parent f906b91 commit 4b523bc139a05a52a58811623d638c43d398f245 @simonmar simonmar committed May 22, 2012
Showing with 18 additions and 15 deletions.
  1. +18 −15 compiler/utils/Panic.lhs
View
33 compiler/utils/Panic.lhs
@@ -243,7 +243,7 @@ installSignalHandlers = do
interrupt_exn = (toException UserInterrupt)
interrupt = do
- mt <- popInterruptTargetThread
+ mt <- peekInterruptTargetThread
case mt of
Nothing -> return ()
Just t -> throwTo t interrupt_exn
@@ -280,33 +280,36 @@ interruptTargetThread = unsafePerformIO (newMVar [])
pushInterruptTargetThread :: ThreadId -> IO ()
pushInterruptTargetThread tid = do
wtid <- mkWeakThreadId tid
- modifyMVar_ interruptTargetThread $
- return . (wtid :)
+ modifyMVar_ interruptTargetThread $ return . (wtid :)
-popInterruptTargetThread :: IO (Maybe ThreadId)
-popInterruptTargetThread =
- modifyMVar interruptTargetThread $ loop
+peekInterruptTargetThread :: IO (Maybe ThreadId)
+peekInterruptTargetThread =
+ withMVar interruptTargetThread $ loop
where
- loop [] = return ([], Nothing)
+ loop [] = return Nothing
loop (t:ts) = do
r <- deRefWeak t
case r of
Nothing -> loop ts
- Just t -> return (ts, Just t)
+ Just t -> return (Just t)
#else
{-# NOINLINE interruptTargetThread #-}
interruptTargetThread :: MVar [ThreadId]
interruptTargetThread = unsafePerformIO (newMVar [])
pushInterruptTargetThread :: ThreadId -> IO ()
pushInterruptTargetThread tid = do
- modifyMVar_ interruptTargetThread $
- return . (tid :)
+ modifyMVar_ interruptTargetThread $ return . (tid :)
-popInterruptTargetThread :: IO (Maybe ThreadId)
-popInterruptTargetThread =
- modifyMVar interruptTargetThread $
- \tids -> return $! case tids of [] -> ([], Nothing)
- (t:ts) -> (ts, Just t)
+peekInterruptTargetThread :: IO (Maybe ThreadId)
+peekInterruptTargetThread =
+ withMVar interruptTargetThread $ return . listToMaybe
#endif
+
+popInterruptTargetThread :: IO ()
+popInterruptTargetThread =
+ modifyMVar_ interruptTargetThread $
+ \tids -> return $! case tids of [] -> []
+ (t:ts) -> ts
+
\end{code}

0 comments on commit 4b523bc

Please sign in to comment.