Merge branch 'master' into rawfilepath

This commit is contained in:
Joey Hess 2020-11-02 14:35:46 -04:00
commit c41be0d3bd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
13 changed files with 300 additions and 7 deletions

View file

@ -55,14 +55,20 @@ startExternalAddonProcess basecmd pid = do
started cmd errrelayer pall@(Just hin, Just hout, Just herr, ph) = do
stderrelay <- async $ errrelayer herr
let shutdown forcestop = do
cancel stderrelay
-- Close the process's stdin, to let it know there
-- are no more requests, so it will exit.
hClose hout
-- Close the procces's stdout as we're not going to
-- process any more output from it.
hClose hin
if forcestop
then cleanupProcess pall
else flip onException (cleanupProcess pall) $ do
hClose herr
hClose hin
hClose hout
void $ waitForProcess ph
else void (waitForProcess ph)
`onException` cleanupProcess pall
-- This thread will exit after consuming any
-- remaining stderr from the process.
wait stderrelay
hClose herr
return $ ExternalAddonProcess
{ externalSend = hin
, externalReceive = hout