diff options
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/INotify.hs | 2 | ||||
-rw-r--r-- | Utility/Process.hs | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/Utility/INotify.hs b/Utility/INotify.hs index 66c0ab23d..6af022819 100644 --- a/Utility/INotify.hs +++ b/Utility/INotify.hs @@ -160,7 +160,7 @@ tooManyWatches hook dir = do querySysctl :: Read a => [CommandParam] -> IO (Maybe a) querySysctl ps = do - v <- catchMaybeIO $ readProcess "sysctl" (toCommand ps) [] + v <- catchMaybeIO $ readProcess "sysctl" (toCommand ps) case v of Nothing -> return Nothing Just s -> return $ parsesysctl s diff --git a/Utility/Process.hs b/Utility/Process.hs index 9b57c3b7a..3b293df4f 100644 --- a/Utility/Process.hs +++ b/Utility/Process.hs @@ -22,6 +22,7 @@ module Utility.Process ( withBothHandles, createProcess, runInteractiveProcess, + writeReadProcess, readProcess ) where @@ -192,11 +193,22 @@ runInteractiveProcess f args c e = do } System.Process.runInteractiveProcess f args c e -readProcess +{- I think this is a more descriptive name than System.Process.readProcess. -} +writeReadProcess :: FilePath -> [String] -> String -> IO String -readProcess f args input = do - debugProcess $ (proc f args) { std_out = CreatePipe } +writeReadProcess f args input = do + debugProcess $ (proc f args) { std_out = CreatePipe, std_in = CreatePipe } System.Process.readProcess f args input + +{- Normally, when reading from a process, it does not need to be fed any + - input. -} +readProcess + :: FilePath + -> [String] + -> IO String +readProcess f args = do + debugProcess $ (proc f args) { std_out = CreatePipe } + System.Process.readProcess f args [] |