diff options
author | 2012-10-12 12:19:30 -0400 | |
---|---|---|
committer | 2012-10-12 12:19:30 -0400 | |
commit | a0b643354907628a16f927935de0396382239c59 (patch) | |
tree | 1641aa8f5309f4d50631555c00df86ec3729a6a7 /Utility/Process.hs | |
parent | 4a63cdd9008bfe34af01c3662af512927a0cee0b (diff) |
Fix a crash when merging files in the git-annex branch that contain invalid utf8.
The crash actually occurred when writing out the file, which was done to a
handle that had not had fileSystemEncoding applied to it.
Diffstat (limited to 'Utility/Process.hs')
-rw-r--r-- | Utility/Process.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Utility/Process.hs b/Utility/Process.hs index db24bf47e..613dd8b0f 100644 --- a/Utility/Process.hs +++ b/Utility/Process.hs @@ -64,17 +64,24 @@ readProcessEnv cmd args environ = , env = environ } -{- Writes stdout to a process, returns its output, and also allows specifying - - the environment. -} +{- Writes a string to a process on its stdout, + - returns its output, and also allows specifying the environment. + - + - + -} writeReadProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] - -> String + -> String + -> (Maybe (Handle -> IO ())) -> IO String -writeReadProcessEnv cmd args environ input = do +writeReadProcessEnv cmd args environ input adjusthandle = do (Just inh, Just outh, _, pid) <- createProcess p + maybe (return ()) (\a -> a inh) adjusthandle + maybe (return ()) (\a -> a outh) adjusthandle + -- fork off a thread to start consuming the output output <- hGetContents outh outMVar <- newEmptyMVar |