summaryrefslogtreecommitdiff
path: root/src/Utility/Process/NonConcurrent.hs
diff options
context:
space:
mode:
authorJoey Hess2016-03-06 20:54:22 -0400
committerJoey Hess2016-03-06 20:54:22 -0400
commit6cb5e3bbf5bf05637d71695ebc001be103526782 (patch)
tree09324a71087268d915948f59208770d308927b6f /src/Utility/Process/NonConcurrent.hs
parent4d09233efd8ad7a238f8002d1aa4cfe3a37013e6 (diff)
parentcef0ee73bb57980bb084025971734cb158842fdc (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Utility/Process/NonConcurrent.hs')
-rw-r--r--src/Utility/Process/NonConcurrent.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Utility/Process/NonConcurrent.hs b/src/Utility/Process/NonConcurrent.hs
new file mode 100644
index 00000000..d25d2a24
--- /dev/null
+++ b/src/Utility/Process/NonConcurrent.hs
@@ -0,0 +1,35 @@
+{- 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
+import Control.Applicative
+import Prelude
+
+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