diff options
Diffstat (limited to 'WaitForSignal.hs')
-rw-r--r-- | WaitForSignal.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/WaitForSignal.hs b/WaitForSignal.hs new file mode 100644 index 00000000..6252eaa6 --- /dev/null +++ b/WaitForSignal.hs | |||
@@ -0,0 +1,10 @@ | |||
1 | module WaitForSignal where | ||
2 | |||
3 | import Control.Concurrent.STM | ||
4 | import System.Posix.Signals | ||
5 | |||
6 | waitForTermSignal = do | ||
7 | quitVar <- newEmptyTMVarIO | ||
8 | installHandler sigTERM (CatchOnce (atomically $ putTMVar quitVar True)) Nothing | ||
9 | installHandler sigINT (CatchOnce (atomically $ putTMVar quitVar True)) Nothing | ||
10 | atomically $ takeTMVar quitVar | ||