#1619: The RTS chokes on SIGPIPE (happens with runInteractiveCommand)
-----------------------------+----------------------------------------------
  Reporter:  int-e           |          Owner:       
      Type:  bug             |         Status:  new  
  Priority:  normal          |      Milestone:       
 Component:  Runtime System  |        Version:  6.7  
  Severity:  normal          |       Keywords:       
Difficulty:  Unknown         |             Os:  Linux
  Testcase:                  |   Architecture:  x86  
-----------------------------+----------------------------------------------
Consider the following code.

 {{{
 -- code based on example by steven_ashley on #haskell
 import System.Process
 import System.IO
 import Control.Exception

 main = do
     data <- readFile "core"
     (inp,out,err,pid) <- runInteractiveCommand "cat"
     print "before"
     finally (hPutStr inp data)
             (print "after")
 }}}

 This program, when run with a large enough {{{core}}} file in the current
 directory, will print {{{"before"}}} and then exit.

 What happens (according to {{{strace}}}) is that the RTS closes the input
 end of the output pipe of the {{{cat}}} process (the one associated with
 the {{{out}}} variable). Then, {{{cat}}} tries to write some of its output
 and gets killed by {{{SIGPIPE}}}. This in turn closes the input end of its
 input pipe. When the Haskell program writes its next chunk of data, it is
 killed by {{{SIGPIPE}}} itself.

 I believe the right fix for this is for the RTS to ignore {{{SIGPIPE}}}.
 The write syscall would then return {{{EPIPE}}} in the above scenario,
 which can be handled by the normal exception mechanism.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1619>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to