Remove uses of compose(s) in tests
[packages/unix.git] / tests / signals004.hs
1 import Control.Concurrent
2 import System.Posix
3 import Control.Monad
4
5 -- signal stress test: threads installing signal handlers while
6 -- signals are being constantly thrown and caught.
7
8 installers = 50
9 -- too many signals overflows the IO manager's pipe buffer, this seems
10 -- to be the most we can get away with:
11 sigs = 400
12
13 main = do
14 c <- newChan
15 m <- newEmptyMVar
16 installHandler sigUSR1 (handler c) Nothing
17 replicateM_ installers (forkIO $ do replicateM_ 1000 (install c); putMVar m ())
18 replicateM_ sigs (forkIO $ raiseSignal sigUSR1)
19 replicateM_ installers (takeMVar m)
20 replicateM_ sigs (readChan c)
21
22 handler c = Catch (writeChan c ())
23
24 install c = do
25 old <- installHandler sigUSR1 (handler c) Nothing
26 installHandler sigUSR1 old Nothing