summaryrefslogtreecommitdiff
path: root/WaitForSignal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'WaitForSignal.hs')
-rw-r--r--WaitForSignal.hs10
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 @@
1module WaitForSignal where
2
3import Control.Concurrent.STM
4import System.Posix.Signals
5
6waitForTermSignal = 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