blob: e4a8486a38d4b7698f6708108268f4fcea60b075 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import Control.Concurrent
import Control.Exception
import System.IO
import System.Posix
import System.Posix.IO
main = do
(pout1, pin1) <- createPipe
(pout2, _) <- createPipe
pid <- forkProcess $ do
hdl <- fdToHandle pin1
hSetBuffering hdl LineBuffering
handle (\UserInterrupt{} -> hPutStrLn hdl "caught")
$ do hPutStrLn hdl "registered"
hdl2 <- fdToHandle pout2
putStrLn =<< hGetLine hdl2
hdl <- fdToHandle pout1
hSetBuffering hdl LineBuffering
"registered" <- hGetLine hdl
signalProcess sigINT pid
putStrLn =<< hGetLine hdl
|