forked from GitHub/gf-core
Block SIGINT while running gfInteract, as suggested by Peter.
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user