summaryrefslogtreecommitdiff
path: root/WaitForSignal.hs
blob: 6252eaa62be820e15dbd789cb69a7dd1600dffa8 (plain)
1
2
3
4
5
6
7
8
9
10
module WaitForSignal where

import Control.Concurrent.STM
import System.Posix.Signals

waitForTermSignal = do
    quitVar <- newEmptyTMVarIO
    installHandler sigTERM (CatchOnce (atomically $ putTMVar quitVar True)) Nothing
    installHandler sigINT (CatchOnce (atomically $ putTMVar quitVar True)) Nothing
    atomically $ takeTMVar quitVar