1
0
forked from GitHub/gf-core

Block SIGINT while running gfInteract, as suggested by Peter.

This commit is contained in:
bringert
2006-06-15 01:41:18 +00:00
parent 3efba2f5cc
commit afac97b821
4 changed files with 16 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ import GF.Shell.SubShell
import GF.Shell.ShellCommands import GF.Shell.ShellCommands
import GF.Shell.PShell import GF.Shell.PShell
import GF.Shell.JGF import GF.Shell.JGF
import GF.System.Signal
import GF.Text.UTF8 import GF.Text.UTF8
import GF.Today (today,version) import GF.Today (today,version)
@@ -84,7 +85,7 @@ main = do
st <- useIOE st0 $ st <- useIOE st0 $
foldM (shellStateFromFiles os) st0 fs foldM (shellStateFromFiles os) st0 fs
if null fs then return () else (ifNotSil putCPU) if null fs then return () else (ifNotSil putCPU)
gfInteract (initHState st) blockInterrupt (gfInteract (initHState st))
return () return ()
-- preprocessing gfe -- preprocessing gfe
if opt fromExamples if opt fromExamples

View File

@@ -24,3 +24,6 @@ runInterruptibly a =
p `catch` h p `catch` h
where p = a >>= \x -> return $! Right $! x where p = a >>= \x -> return $! Right $! x
h e = return $ Left e h e = return $ Left e
blockInterrupt :: IO a -> IO a
blockInterrupt = id

View File

@@ -14,14 +14,14 @@
-- Import the right singal handling module. -- Import the right singal handling module.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module GF.System.Signal (runInterruptibly) where module GF.System.Signal (runInterruptibly,blockInterrupt) where
#ifdef USE_INTERRUPT #ifdef USE_INTERRUPT
import GF.System.UseSignal (runInterruptibly) import GF.System.UseSignal (runInterruptibly,blockInterrupt)
#else #else
import GF.System.NoSignal (runInterruptibly) import GF.System.NoSignal (runInterruptibly,blockInterrupt)
#endif #endif

View File

@@ -48,3 +48,11 @@ runInterruptibly a =
-- the computation fails or not. -- the computation fails or not.
runInterruptibly_ :: IO () -> IO () runInterruptibly_ :: IO () -> IO ()
runInterruptibly_ = fmap (either (const ()) id) . runInterruptibly 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