Ticket #2454: SilentClose.hs

File SilentClose.hs, 426 bytes (added by cjs, 7 years ago)

Program to demonstrate hClose silent failure.

Line 
1module Main where
2
3import System.IO
4import System.Process
5
6main = do (pin, pout, perr, procHandle) <- runInteractiveProcess "/x/y/z" []
7                                               Nothing Nothing
8          putStrLn "Started child process."
9          hPutStrLn pin "some text"
10          putStrLn "Wrote to child's stdin."
11          hClose pin `catch` (\ioe -> putStrLn (show ioe))
12          putStrLn "Closed child's stdin."