diff options
author | joe <joe@jerkface.net> | 2014-03-12 21:24:09 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-03-12 21:24:09 -0400 |
commit | a778899096731cc087df795d8107bebf10efe59e (patch) | |
tree | e6c262264cb48e111819c1510e9763f5fab71ce1 /WaitForSignal.hs | |
parent | 7167550ca24975e06e028de7c797612fff82a16d (diff) |
consolation demo program
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 | ||