From c1a6f81c7ef7095273c6665521ac156c82e6b687 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Nov 2014 16:10:13 -0400 Subject: better IO loop, with debugging --- src/Propellor/CmdLine.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index ea2fadad..f8d5d57d 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -12,7 +12,7 @@ import Control.Exception (bracket) import System.Posix.IO import Data.Time.Clock.POSIX import Control.Concurrent.Async -import qualified Data.ByteString.Lazy as B +import qualified Data.ByteString as B import System.Process (std_in, std_out) import Propellor @@ -317,10 +317,17 @@ gitPush hin hout = void $ fromstdin `concurrently` tostdout where fromstdin = do h <- fdToHandle hout - B.getContents >>= B.hPut h + connect stdin h tostdout = do h <- fdToHandle hin - B.hGetContents h >>= B.putStr + connect h stdout + connect fromh toh = do + b <- B.hGetSome fromh 40960 + unless (B.null b) $ do + hPutStrLn stderr $ show ("got", fromh, b) + B.hPut toh b + hFlush toh + connect fromh toh hasOrigin :: IO Bool hasOrigin = do -- cgit v1.2.3