@@ -48,14 +48,14 @@ import Cardano.Tracer.MetaTrace hiding (traceWith)
48
48
import Cardano.Tracer.Types
49
49
import Ouroboros.Network.Socket (ConnectionId (.. ))
50
50
51
- import Control.Concurrent (killThread , mkWeakThreadId , myThreadId )
51
+ import Control.Concurrent (mkWeakThreadId , myThreadId )
52
52
import Control.Concurrent.Async (Concurrently (.. ))
53
53
import Control.Concurrent.Extra (Lock )
54
54
import Control.Concurrent.MVar (newMVar , swapMVar , readMVar , tryReadMVar , modifyMVar_ )
55
55
import Control.Concurrent.STM (atomically )
56
56
import 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 )
59
59
import Control.Monad (forM_ )
60
60
import Control.Monad.Extra (whenJustM )
61
61
import "contra-tracer" Control.Tracer (stdoutTracer , traceWith )
@@ -68,9 +68,10 @@ import Data.List.Extra (dropPrefix, dropSuffix, replace)
68
68
import qualified Data.Map.Strict as Map
69
69
import qualified Data.Set as S
70
70
import qualified Data.Text as T
71
+ import System.Exit (ExitCode (ExitSuccess ))
71
72
import System.IO (hClose , hFlush , stdout )
72
73
import System.Mem.Weak (deRefWeak )
73
- import qualified System.Signal as S
74
+ import qualified System.Signal as Signal
74
75
import System.Time.Extra (sleep )
75
76
76
77
#if defined(mingw32_HOST_OS)
@@ -243,16 +244,16 @@ beforeProgramStops :: IO () -> IO ()
243
244
beforeProgramStops action = do
244
245
mainThreadIdWk <- mkWeakThreadId =<< myThreadId
245
246
forM_ signals $ \ sig ->
246
- S . installHandler sig . const $ do
247
+ Signal . installHandler sig \ _ -> do
247
248
putStrLn " Program is stopping, please wait..."
248
249
hFlush stdout
249
- action
250
- `finally` whenJustM (deRefWeak mainThreadIdWk) killThread
250
+ action `finally`
251
+ whenJustM (deRefWeak mainThreadIdWk) ( `throwTo` ExitSuccess )
251
252
where
253
+ signals :: [Signal. Signal ]
252
254
signals =
253
- [ S. sigABRT
254
- , S. sigINT
255
- , S. sigTERM
255
+ [ Signal. sigINT
256
+ , Signal. sigTERM
256
257
]
257
258
258
259
memberRegistry :: Ord a => a -> Registry a b -> IO Bool
0 commit comments