refactor
This commit is contained in:
parent
014d6d4f31
commit
750a3ca22f
1 changed files with 3 additions and 8 deletions
|
@ -177,10 +177,7 @@ processTranscript cmd opts input = do
|
||||||
}
|
}
|
||||||
hClose writeh
|
hClose writeh
|
||||||
|
|
||||||
-- fork off a thread to start consuming the output
|
get <- mkreader readh
|
||||||
transcript <- hGetContents readh
|
|
||||||
outMVar <- newEmptyMVar
|
|
||||||
_ <- forkIO $ E.evaluate (length transcript) >> putMVar outMVar ()
|
|
||||||
|
|
||||||
-- now write and flush any input
|
-- now write and flush any input
|
||||||
case input of
|
case input of
|
||||||
|
@ -192,9 +189,7 @@ processTranscript cmd opts input = do
|
||||||
hClose inh
|
hClose inh
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
|
|
||||||
-- wait on the output
|
transcript <- get
|
||||||
takeMVar outMVar
|
|
||||||
hClose readh
|
|
||||||
|
|
||||||
ok <- checkSuccessProcess pid
|
ok <- checkSuccessProcess pid
|
||||||
return (transcript, ok)
|
return (transcript, ok)
|
||||||
|
@ -223,6 +218,7 @@ processTranscript cmd opts input = do
|
||||||
transcript <- (++) <$> getout <*> geterr
|
transcript <- (++) <$> getout <*> geterr
|
||||||
ok <- checkSuccessProcess pid
|
ok <- checkSuccessProcess pid
|
||||||
return (transcript, ok)
|
return (transcript, ok)
|
||||||
|
#endif
|
||||||
where
|
where
|
||||||
mkreader h = do
|
mkreader h = do
|
||||||
s <- hGetContents h
|
s <- hGetContents h
|
||||||
|
@ -233,7 +229,6 @@ processTranscript cmd opts input = do
|
||||||
return $ do
|
return $ do
|
||||||
takeMVar v
|
takeMVar v
|
||||||
return s
|
return s
|
||||||
#endif
|
|
||||||
|
|
||||||
{- Runs a CreateProcessRunner, on a CreateProcess structure, that
|
{- Runs a CreateProcessRunner, on a CreateProcess structure, that
|
||||||
- is adjusted to pipe only from/to a single StdHandle, and passes
|
- is adjusted to pipe only from/to a single StdHandle, and passes
|
||||||
|
|
Loading…
Add table
Reference in a new issue