#2220: Subprocesses do not close open FDs
-------------------------+--------------------------------------------------
    Reporter:  Baughn    |       Owner:                
        Type:  bug       |      Status:  new           
    Priority:  normal    |   Component:  Runtime System
     Version:  6.8.2     |    Severity:  normal        
    Keywords:            |    Testcase:                
Architecture:  Multiple  |          Os:  Multiple      
-------------------------+--------------------------------------------------
 When creating a subprocess, for example with runInteractiveProcess, only
 pipes that are created in the process of creating the process are closed
 appropriately; any FDs created elsewhere in the program are ignored. As
 unix pipes are only considered closed once every process that could
 conceivably write to one has closed it, one consequence of this is that
 programs that rely on detecting EOF will be unable to do so. Another is
 that the system may leak FDs over the runtime of the program, conceivably
 running out.

 As an example, this makes it impossible to write a fully functional shell
 with pipes in GHC; in a shell command like "<main program> | cat | cat",
 the second cat may acquire a reference to the pipe used for writing to the
 first one, which will prevent that pipe from ever being considered closed.

 A brute-force solution would be to attempt to close every possible FD when
 creating subprocesses. This is undesirable for several reasons - most
 obviously performance, but also because there are legitimate reasons to
 pass FDs other than stdin/out/err to a subprocess. A more elegant one
 would be for all FDs opened by any means to be marked as close-on-exec on
 creation, and provide a call to clear this bit if transferring it to a
 specific subprocess is desired.

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

Reply via email to