diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-03-06 20:39:44 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-03-06 20:50:52 -0400 |
commit | 979fc0e4c03bf6ccd88873f561040bfa1133111d (patch) | |
tree | 2fd505aef8cf863af079f8a31830a6cc721b304b /src/Utility | |
parent | d09a67ea25be77300a4eeb06b7c922b0c28c5d25 (diff) |
Force ssh, scp, and git commands to be run in the foreground.
Before, they could run in the background if another process was running,
and so their output wouldn't immediately be visible.
With this change, the concurrent-output layer is not used for these
interactive commands.
Diffstat (limited to 'src/Utility')
-rw-r--r-- | src/Utility/Process/NonConcurrent.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Utility/Process/NonConcurrent.hs b/src/Utility/Process/NonConcurrent.hs new file mode 100644 index 00000000..27eb5e92 --- /dev/null +++ b/src/Utility/Process/NonConcurrent.hs @@ -0,0 +1,33 @@ +{- Running processes in the foreground, not via the concurrent-output + - layer. + - + - Avoid using this in propellor properties! + - + - Copyright 2016 Joey Hess <id@joeyh.name> + - + - License: BSD-2-clause + -} + +{-# OPTIONS_GHC -fno-warn-tabs #-} + +module Utility.Process.NonConcurrent where + +import System.Process +import System.Exit +import System.IO +import Utility.SafeCommand + +boolSystemNonConcurrent :: String -> [CommandParam] -> IO Bool +boolSystemNonConcurrent cmd params = do + (Nothing, Nothing, Nothing, p) <- createProcessNonConcurrent $ + proc cmd (toCommand params) + dispatch <$> waitForProcessNonConcurrent p + where + dispatch ExitSuccess = True + dispatch _ = False + +createProcessNonConcurrent :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) +createProcessNonConcurrent = createProcess + +waitForProcessNonConcurrent :: ProcessHandle -> IO ExitCode +waitForProcessNonConcurrent = waitForProcess |