fix exit code propigation

This commit is contained in:
Joey Hess 2012-11-10 00:02:55 -04:00
parent ee0958e044
commit 341d09adc2

View file

@ -163,19 +163,14 @@ relayHandle var = do
- we're talking to git-push on stdout - we're talking to git-push on stdout
- git-receive-pack is talking to us on relayIn (via XMPP) - git-receive-pack is talking to us on relayIn (via XMPP)
- we're talking to git-receive-pack on relayOut (via XMPP) - we're talking to git-receive-pack on relayOut (via XMPP)
- git-receive-pack's exit code will be passed to us on relayControl
-} -}
xmppGitRelay :: IO () xmppGitRelay :: IO ()
xmppGitRelay = do xmppGitRelay = do
flip relay stdout =<< relayHandle relayIn flip relay stdout =<< relayHandle relayIn
relay stdin =<< relayHandle relayOut relay stdin =<< relayHandle relayOut
code <- hGetLine =<< relayHandle relayControl
controlh <- relayHandle relayControl exitWith $ fromMaybe (ExitFailure 1) $ readish code
s <- hGetLine controlh
exitWith $ case readish s of
Just n
| n == 0 -> ExitSuccess
| otherwise -> ExitFailure n
Nothing -> ExitFailure 1
where where
{- Is it possible to set up pipes and not need to copy the data {- Is it possible to set up pipes and not need to copy the data
- ourselves? See splice(2) -} - ourselves? See splice(2) -}