[commit: packages/Cabal] ghc-head: make rawSystemIOWithEnv close its handles (fb2a6a1)

git at git.haskell.org git at git.haskell.org
Wed Oct 16 06:33:19 UTC 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/packages/Cabal.git/commitdiff/fb2a6a1d4081a0a8007961a5e198932322bf8c24

>---------------------------------------------------------------

commit fb2a6a1d4081a0a8007961a5e198932322bf8c24
Author: Luite Stegeman <stegeman at gmail.com>
Date:   Mon Oct 14 20:59:35 2013 +0200

    make rawSystemIOWithEnv close its handles
    
    (cherry picked from commit f6dae3813effa7cf1855b793a87a2b0efddf2f7e)


>---------------------------------------------------------------

fb2a6a1d4081a0a8007961a5e198932322bf8c24
 Cabal/Distribution/Simple/Utils.hs |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs
index fdd5605..45890ee 100644
--- a/Cabal/Distribution/Simple/Utils.hs
+++ b/Cabal/Distribution/Simple/Utils.hs
@@ -175,7 +175,7 @@ import System.Directory
 import System.IO
     ( Handle, openFile, openBinaryFile, openBinaryTempFile
     , IOMode(ReadMode), hSetBinaryMode
-    , hGetContents, stderr, stdout, hPutStr, hFlush, hClose )
+    , hGetContents, stdin, stderr, stdout, hPutStr, hFlush, hClose )
 import System.IO.Error as IO.Error
     ( isDoesNotExistError, isAlreadyExistsError
     , ioeSetFileName, ioeGetFileName, ioeGetErrorString )
@@ -473,9 +473,15 @@ rawSystemIOWithEnv verbosity path args mcwd menv inp out err = do
                 , Process.std_err = mbToStd err }
     unless (exitcode == ExitSuccess) $ do
       debug verbosity $ path ++ " returned " ++ show exitcode
+    mapM_ maybeClose [inp, out, err]
     return exitcode
   where
   -- Also taken from System.Process
+  maybeClose :: Maybe Handle -> IO ()
+  maybeClose (Just  hdl)
+    | hdl /= stdin && hdl /= stdout && hdl /= stderr = hClose hdl
+  maybeClose _ = return ()
+
   mbToStd :: Maybe Handle -> StdStream
   mbToStd Nothing    = Inherit
   mbToStd (Just hdl) = UseHandle hdl



More information about the ghc-commits mailing list