runInteractiveCommand dying uncatchably?

If I run the following program, it never prints "done". If I uncomment the commented line, it does. import Prelude hiding (catch) import Control.Exception import System.Process import System.IO demo = do putStrLn "starting" (inp,out,err,pid) <- runInteractiveCommand "nonesuchcommand" putStrLn "writing to in on bad command" hPutStr inp "whatever" -- putStr "flushing" hFlush inp `catch` \e -> do print e; return () putStrLn "done" main = demo `catch` \e -> do print e; return () On my machine the output is: $ runhaskell test.hs starting writing to in on bad command $ It appears to exit at the hFlush call. (hClose has the same behavior.) I find this surprising -- I'd expect, even if I'm using an API incorrectly, to get an exception.

On Mar 1, 2008, at 13:39 , Evan Martin wrote:
If I run the following program, it never prints "done". If I uncomment the commented line, it does.
The exception it's getting is a UNIX signal (SIGPIPE), whose default action if not caught is to silently kill the process. Establish a signal handler for sigPIPE, or ignore it (which will silently convert it to an error EPIPE which will raise a normal I/O exception). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (2)
-
Brandon S. Allbery KF8NH
-
Evan Martin