convert to withCreateProcess for async exception safety

This handles all sites where checkSuccessProcess/ignoreFailureProcess
is used, except for one: Git.Command.pipeReadLazy
That one will be significantly more work to convert to bracketing.

(Also skipped Command.Assistant.autoStart, but it does not need to
shut down the processes it started on exception because they are
git-annex assistant daemons..)

forceSuccessProcess is done, except for createProcessSuccess.
All call sites of createProcessSuccess will need to be converted
to bracketing.

(process pools still todo also)
This commit is contained in:
Joey Hess 2020-06-04 12:13:26 -04:00
parent 2dc7b5186a
commit 438dbe3b66
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
13 changed files with 125 additions and 87 deletions

View file

@ -1,6 +1,6 @@
{- running git commands
-
- Copyright 2010-2013 Joey Hess <id@joeyh.name>
- Copyright 2010-2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -70,13 +70,17 @@ pipeReadStrict = pipeReadStrict' S.hGetContents
{- The reader action must be strict. -}
pipeReadStrict' :: (Handle -> IO a) -> [CommandParam] -> Repo -> IO a
pipeReadStrict' reader params repo = assertLocal repo $
withHandle StdoutHandle (createProcessChecked ignoreFailureProcess) p $ \h -> do
output <- reader h
hClose h
return output
pipeReadStrict' reader params repo = assertLocal repo $ withCreateProcess p go
where
p = gitCreateProcess params repo
p = (gitCreateProcess params repo)
{ std_out = CreatePipe }
go _ (Just outh) _ pid = do
output <- reader outh
hClose outh
void $ waitForProcess pid
return output
go _ _ _ _ = error "internal"
{- Runs a git command, feeding it an input, and returning its output,
- which is expected to be fairly small, since it's all read into memory