Commit f6dae381 authored by Luite Stegeman's avatar Luite Stegeman
Browse files

make rawSystemIOWithEnv close its handles

parent e5b06109
...@@ -175,7 +175,7 @@ import System.Directory ...@@ -175,7 +175,7 @@ import System.Directory
import System.IO import System.IO
( Handle, openFile, openBinaryFile, openBinaryTempFile ( Handle, openFile, openBinaryFile, openBinaryTempFile
, IOMode(ReadMode), hSetBinaryMode , IOMode(ReadMode), hSetBinaryMode
, hGetContents, stderr, stdout, hPutStr, hFlush, hClose ) , hGetContents, stdin, stderr, stdout, hPutStr, hFlush, hClose )
import System.IO.Error as IO.Error import System.IO.Error as IO.Error
( isDoesNotExistError, isAlreadyExistsError ( isDoesNotExistError, isAlreadyExistsError
, ioeSetFileName, ioeGetFileName, ioeGetErrorString ) , ioeSetFileName, ioeGetFileName, ioeGetErrorString )
...@@ -473,9 +473,15 @@ rawSystemIOWithEnv verbosity path args mcwd menv inp out err = do ...@@ -473,9 +473,15 @@ rawSystemIOWithEnv verbosity path args mcwd menv inp out err = do
, Process.std_err = mbToStd err } , Process.std_err = mbToStd err }
unless (exitcode == ExitSuccess) $ do unless (exitcode == ExitSuccess) $ do
debug verbosity $ path ++ " returned " ++ show exitcode debug verbosity $ path ++ " returned " ++ show exitcode
mapM_ maybeClose [inp, out, err]
return exitcode return exitcode
where where
-- Also taken from System.Process -- 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 :: Maybe Handle -> StdStream
mbToStd Nothing = Inherit mbToStd Nothing = Inherit
mbToStd (Just hdl) = UseHandle hdl mbToStd (Just hdl) = UseHandle hdl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment