Created
June 13, 2017 14:55
-
-
Save itkovian/6ae1328a0933cfc32dc873a022eb26cb to your computer and use it in GitHub Desktop.
Signal handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handler :: MVar Int -> IO () | |
handler s_interrupted = trace "Interrupt received" $ do | |
r <- readMVar s_interrupted | |
trace ("value was " ++ show r) $ modifyMVar_ s_interrupted (return . (+1)) | |
{- this prints on the first SIGTERM: | |
Interrupt received | |
value was 0 | |
But then each new SIGTERM I only get | |
value was 1 | |
value was 2 | |
value was 3 | |
value was 4 | |
value was 5 | |
value was 6 | |
value was 7 | |
value was 8 | |
value was 9 | |
value was 10 | |
value was 11 | |
value was 12 | |
value was 13 | |
value was 14 | |
value was 15 | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment