summaryrefslogtreecommitdiff
path: root/WaitForSignal.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-12 21:24:09 -0400
committerjoe <joe@jerkface.net>2014-03-12 21:24:09 -0400
commita778899096731cc087df795d8107bebf10efe59e (patch)
treee6c262264cb48e111819c1510e9763f5fab71ce1 /WaitForSignal.hs
parent7167550ca24975e06e028de7c797612fff82a16d (diff)
consolation demo program
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