convert to withCreateProcess for async exception safety
This handles all createProcessSuccess callers, and aside from process pools, the complete conversion of all process running to async exception safety should be complete now. Also, was able to remove from Utility.Process the old API that I now know was not a good idea. And proof it was bad: The code size went *down*, despite there being a fair bit of boilerplate for some future API to reduce.
This commit is contained in:
parent
12e7d52c8b
commit
2670890b17
16 changed files with 196 additions and 191 deletions
|
@ -162,10 +162,15 @@ store' r k b p = go =<< glacierEnv c gc u
|
|||
, Param "-"
|
||||
]
|
||||
go Nothing = giveup "Glacier not usable."
|
||||
go (Just e) = liftIO $ do
|
||||
go (Just e) =
|
||||
let cmd = (proc "glacier" (toCommand params)) { env = Just e }
|
||||
withHandle StdinHandle createProcessSuccess cmd $ \h ->
|
||||
meteredWrite p h b
|
||||
{ std_in = CreatePipe }
|
||||
in liftIO $ withCreateProcess cmd (go' cmd)
|
||||
go' cmd (Just hin) _ _ pid =
|
||||
forceSuccessProcess cmd pid
|
||||
`after`
|
||||
meteredWrite p hin b
|
||||
go' _ _ _ _ _ = error "internal"
|
||||
|
||||
retrieve :: Remote -> Retriever
|
||||
retrieve = byteRetriever . retrieve'
|
||||
|
@ -353,5 +358,10 @@ checkSaneGlacierCommand =
|
|||
giveup wrongcmd
|
||||
where
|
||||
test = proc "glacier" ["--compatibility-test-git-annex"]
|
||||
shouldfail = withQuietOutput createProcessSuccess test
|
||||
shouldfail = withNullHandle $ \nullh ->
|
||||
let p = test
|
||||
{ std_out = UseHandle nullh
|
||||
, std_err = UseHandle nullh
|
||||
}
|
||||
in withCreateProcess p $ \_ _ _ -> forceSuccessProcess p
|
||||
wrongcmd = "The glacier program in PATH seems to be from boto, not glacier-cli. Cannot use this program."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue