#4493: Child from forkProcess calls select/read on parent's Handle, stealing
data
from parent
------------------------------------------+---------------------------------
Reporter: josh | Owner: simonmar
Type: bug | Status: closed
Priority: high | Milestone: 7.0.2
Component: Runtime System | Version: 6.12.1
Resolution: invalid | Keywords:
Testcase: yes | Blockedby:
Difficulty: | Os: Linux
Blocking: | Architecture: x86_64 (amd64)
Failure: Incorrect result at runtime |
------------------------------------------+---------------------------------
Changes (by simonmar):
* status: new => closed
* resolution: => invalid
Comment:
This is lazy I/O. What is happening is that the filename passed to the
child process is partly unevaluated (thanks to `lines` being nice and
lazy), and when the child process demands it, it tries to read the data
from the original pipe.
If you change the program to
{{{
import System.Cmd.Utils
main = do
(h, stream) <- pipeFrom "find" ["."]
mapM (\file -> length file `seq` pipeFrom "ls" ["-l", file]) $
lines stream
}}}
then it works.
In `System.Process` we always set our pipe FDs to `FD_CLOEXEC` which would
give you a nicer error message in this case - the child would fail when
trying to read the parent's pipe. I think MissingH doesn't do that (it
might be a good idea to suggest making that change to John Goerzen).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4493#comment:6>
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