Add tests for the top level exception handler
[ghc.git] / libraries / base / tests / topHandler01.hs
1 import System.Posix.Process
2 import System.Posix.Signals
3 import Control.Exception
4 import Control.Concurrent
5
6 -- Test that a simulated ^C sends an async UserInterrupt
7 -- exception to the main thread.
8
9 main = handle userInterrupt $ do
10 us <- getProcessID
11 signalProcess sigINT us
12 threadDelay 1000000
13 putStrLn "Fail: never received exception"
14
15 userInterrupt UserInterrupt = putStrLn "Success: caught UserInterrupt"
16 userInterrupt e = putStrLn "Fail: caught unexpected exception"