diff options
| author | Joey Hess <joey@kitenet.net> | 2014-11-20 00:58:51 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-11-20 00:58:51 -0400 |
| commit | 02b8b2dec7c767ba3b7154e424b9c11e6a8d544f (patch) | |
| tree | 84f8394029d0b17de94a47ea59dd29b70d5bab38 /src/Utility/Process.hs | |
| parent | f1b2df601e0eb2fdd5dbc3bc72df0f0493230046 (diff) | |
| parent | 0d4dd37ee769a6ef1bc80507c8ee8a4b9e882856 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Utility/Process.hs')
| -rw-r--r-- | src/Utility/Process.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Utility/Process.hs b/src/Utility/Process.hs index cd3826d7..4550d94f 100644 --- a/src/Utility/Process.hs +++ b/src/Utility/Process.hs @@ -10,9 +10,10 @@ module Utility.Process ( module X, - CreateProcess, + CreateProcess(..), StdHandle(..), readProcess, + readProcess', readProcessEnv, writeReadProcessEnv, forceSuccessProcess, @@ -31,6 +32,7 @@ module Utility.Process ( stdinHandle, stdoutHandle, stderrHandle, + bothHandles, processHandle, devNull, ) where @@ -65,17 +67,19 @@ readProcess :: FilePath -> [String] -> IO String readProcess cmd args = readProcessEnv cmd args Nothing readProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] -> IO String -readProcessEnv cmd args environ = - withHandle StdoutHandle createProcessSuccess p $ \h -> do - output <- hGetContentsStrict h - hClose h - return output +readProcessEnv cmd args environ = readProcess' p where p = (proc cmd args) { std_out = CreatePipe , env = environ } +readProcess' :: CreateProcess -> IO String +readProcess' p = withHandle StdoutHandle createProcessSuccess p $ \h -> do + output <- hGetContentsStrict h + hClose h + return output + {- Runs an action to write to a process on its stdin, - returns its output, and also allows specifying the environment. -} |
