@@ -48,14 +48,14 @@ import Cardano.Tracer.MetaTrace hiding (traceWith)
4848import Cardano.Tracer.Types
4949import Ouroboros.Network.Socket (ConnectionId (.. ))
5050
51- import Control.Concurrent (killThread , mkWeakThreadId , myThreadId )
51+ import Control.Concurrent (mkWeakThreadId , myThreadId )
5252import Control.Concurrent.Async (Concurrently (.. ))
5353import Control.Concurrent.Extra (Lock )
5454import Control.Concurrent.MVar (newMVar , swapMVar , readMVar , tryReadMVar , modifyMVar_ )
5555import Control.Concurrent.STM (atomically )
5656import Control.Concurrent.STM.TVar (modifyTVar' , stateTVar , readTVarIO , newTVarIO )
57- import Control.Exception (SomeAsyncException (.. ), SomeException , finally , fromException ,
58- try , tryJust )
57+ import Control.Exception (SomeAsyncException (.. ), SomeException , finally ,
58+ fromException , try , tryJust , throwTo )
5959import Control.Monad (forM_ )
6060import Control.Monad.Extra (whenJustM )
6161import "contra-tracer" Control.Tracer (stdoutTracer , traceWith )
@@ -68,9 +68,10 @@ import Data.List.Extra (dropPrefix, dropSuffix, replace)
6868import qualified Data.Map.Strict as Map
6969import qualified Data.Set as S
7070import qualified Data.Text as T
71+ import System.Exit (ExitCode (ExitSuccess ))
7172import System.IO (hClose , hFlush , stdout )
7273import System.Mem.Weak (deRefWeak )
73- import qualified System.Signal as S
74+ import qualified System.Signal as Signal
7475import System.Time.Extra (sleep )
7576
7677#if defined(mingw32_HOST_OS)
@@ -243,16 +244,16 @@ beforeProgramStops :: IO () -> IO ()
243244beforeProgramStops action = do
244245 mainThreadIdWk <- mkWeakThreadId =<< myThreadId
245246 forM_ signals $ \ sig ->
246- S . installHandler sig . const $ do
247+ Signal . installHandler sig \ _ -> do
247248 putStrLn " Program is stopping, please wait..."
248249 hFlush stdout
249- action
250- `finally` whenJustM (deRefWeak mainThreadIdWk) killThread
250+ action `finally`
251+ whenJustM (deRefWeak mainThreadIdWk) ( `throwTo` ExitSuccess )
251252 where
253+ signals :: [Signal. Signal ]
252254 signals =
253- [ S. sigABRT
254- , S. sigINT
255- , S. sigTERM
255+ [ Signal. sigINT
256+ , Signal. sigTERM
256257 ]
257258
258259memberRegistry :: Ord a => a -> Registry a b -> IO Bool
0 commit comments