The RTS chokes on SIGPIPE (happens with runInteractiveCommand)
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.
Trac metadata
Trac field | Value |
---|---|
Version | 6.7 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |