summaryrefslogtreecommitdiff
path: root/src/GF/System
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2006-06-15 01:41:18 +0000
committerbringert <bringert@cs.chalmers.se>2006-06-15 01:41:18 +0000
commitafac97b82181e2db14226d854761e53c66d98094 (patch)
treea3c61f6b04359f4ce0289bd4ba0863467cc2ea66 /src/GF/System
parent3efba2f5cc795bd4bbf65224d2c20ce92f6f4a5f (diff)
Block SIGINT while running gfInteract, as suggested by Peter.
Diffstat (limited to 'src/GF/System')
-rw-r--r--src/GF/System/NoSignal.hs3
-rw-r--r--src/GF/System/Signal.hs6
-rw-r--r--src/GF/System/UseSignal.hs8
3 files changed, 14 insertions, 3 deletions
diff --git a/src/GF/System/NoSignal.hs b/src/GF/System/NoSignal.hs
index 5b7827f32..fdad89b27 100644
--- a/src/GF/System/NoSignal.hs
+++ b/src/GF/System/NoSignal.hs
@@ -24,3 +24,6 @@ runInterruptibly a =
p `catch` h
where p = a >>= \x -> return $! Right $! x
h e = return $ Left e
+
+blockInterrupt :: IO a -> IO a
+blockInterrupt = id \ No newline at end of file
diff --git a/src/GF/System/Signal.hs b/src/GF/System/Signal.hs
index 3d9e6ef40..fe8a12483 100644
--- a/src/GF/System/Signal.hs
+++ b/src/GF/System/Signal.hs
@@ -14,14 +14,14 @@
-- Import the right singal handling module.
-----------------------------------------------------------------------------
-module GF.System.Signal (runInterruptibly) where
+module GF.System.Signal (runInterruptibly,blockInterrupt) where
#ifdef USE_INTERRUPT
-import GF.System.UseSignal (runInterruptibly)
+import GF.System.UseSignal (runInterruptibly,blockInterrupt)
#else
-import GF.System.NoSignal (runInterruptibly)
+import GF.System.NoSignal (runInterruptibly,blockInterrupt)
#endif
diff --git a/src/GF/System/UseSignal.hs b/src/GF/System/UseSignal.hs
index 8f3874711..5e6d81237 100644
--- a/src/GF/System/UseSignal.hs
+++ b/src/GF/System/UseSignal.hs
@@ -48,3 +48,11 @@ runInterruptibly a =
-- the computation fails or not.
runInterruptibly_ :: IO () -> IO ()
runInterruptibly_ = fmap (either (const ()) id) . runInterruptibly
+
+-- | Run an action with SIGINT blocked.
+blockInterrupt :: IO a -> IO a
+blockInterrupt a =
+ do oldH <- installHandler sigINT Ignore Nothing
+ x <- a
+ installHandler sigINT oldH Nothing
+ return x