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:
parent
2dc7b5186a
commit
438dbe3b66
13 changed files with 125 additions and 87 deletions
|
@ -180,14 +180,16 @@ querySingle o r repo reader = assertLocal repo $
|
|||
, std_in = Inherit
|
||||
, std_out = CreatePipe
|
||||
}
|
||||
pid <- createProcess p'
|
||||
let h = stdoutHandle pid
|
||||
output <- reader h
|
||||
hClose h
|
||||
ifM (checkSuccessProcess (processHandle pid))
|
||||
withCreateProcess p' go
|
||||
where
|
||||
go _ (Just outh) _ pid = do
|
||||
output <- reader outh
|
||||
hClose outh
|
||||
ifM (checkSuccessProcess pid)
|
||||
( return (Just output)
|
||||
, return Nothing
|
||||
)
|
||||
go _ _ _ _ = error "internal"
|
||||
|
||||
querySize :: Ref -> Repo -> IO (Maybe FileSize)
|
||||
querySize r repo = maybe Nothing (readMaybe . takeWhile (/= '\n'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue