summaryrefslogtreecommitdiff
path: root/src/Utility
diff options
context:
space:
mode:
authorJoey Hess2015-10-28 11:44:05 -0400
committerJoey Hess2015-10-28 11:44:05 -0400
commit21a74a3ffea3d48195d76486a56031b317fa23fa (patch)
tree36772b12f03adafe57d12ee176544660537fafce /src/Utility
parent0b9c4a5396876d06406a67e0ee4dcfd1820f677a (diff)
propellor spin
Diffstat (limited to 'src/Utility')
-rw-r--r--src/Utility/ConcurrentOutput.hs28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/Utility/ConcurrentOutput.hs b/src/Utility/ConcurrentOutput.hs
index 35904cb7..8a4bdcf2 100644
--- a/src/Utility/ConcurrentOutput.hs
+++ b/src/Utility/ConcurrentOutput.hs
@@ -130,23 +130,19 @@ updateOutputLocker l = do
-- as the output lock becomes free.
createProcessConcurrent :: P.CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, P.ProcessHandle)
createProcessConcurrent p
- | hasoutput (P.std_out p) || hasoutput (P.std_err p) =
+ | willoutput (P.std_out p) || willoutput (P.std_err p) =
ifM tryTakeOutputLock
- ( do
- print ("FIRST", pc)
- firstprocess
- , do
- print ("CONCURRENT", pc)
- concurrentprocess
+ ( firstprocess
+ , concurrentprocess
)
| otherwise = P.createProcess p
where
- hasoutput P.Inherit = True
- hasoutput _ = False
+ willoutput P.Inherit = True
+ willoutput _ = False
- pc = case P.cmdspec p of
- P.ShellCommand s -> s
- P.RawCommand c ps -> unwords (c:ps)
+ rediroutput str h
+ | willoutput str = P.UseHandle h
+ | otherwise = str
firstprocess = do
r@(_, _, _, h) <- P.createProcess p
@@ -161,12 +157,8 @@ createProcessConcurrent p
(toouth, fromouth) <- pipe
(toerrh, fromerrh) <- pipe
let p' = p
- { P.std_out = if hasoutput (P.std_out p)
- then P.UseHandle toouth
- else P.std_out p
- , P.std_err = if hasoutput (P.std_err p)
- then P.UseHandle toerrh
- else P.std_err p
+ { P.std_out = rediroutput (P.std_out p) toouth
+ , P.std_err = rediroutput (P.std_err p) toerrh
}
r <- P.createProcess p'
hClose toouth