From 979fc0e4c03bf6ccd88873f561040bfa1133111d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 Mar 2016 20:39:44 -0400 Subject: 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. --- src/Utility/Process/NonConcurrent.hs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Utility/Process/NonConcurrent.hs (limited to 'src/Utility/Process/NonConcurrent.hs') 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 + - + - 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 -- cgit v1.3-2-g0d8e From 57a6e9788953f9ee4714572e5d2c022b66380290 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 Mar 2016 20:52:11 -0400 Subject: build with older ghc --- src/Utility/Process/NonConcurrent.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Utility/Process/NonConcurrent.hs') diff --git a/src/Utility/Process/NonConcurrent.hs b/src/Utility/Process/NonConcurrent.hs index 27eb5e92..d25d2a24 100644 --- a/src/Utility/Process/NonConcurrent.hs +++ b/src/Utility/Process/NonConcurrent.hs @@ -16,6 +16,8 @@ import System.Process import System.Exit import System.IO import Utility.SafeCommand +import Control.Applicative +import Prelude boolSystemNonConcurrent :: String -> [CommandParam] -> IO Bool boolSystemNonConcurrent cmd params = do -- cgit v1.3-2-g0d8e