close send side of password pipe on exec

This avoids a hang approximately 1% of the time when running the test
suite on StatelessOpenPGP.

Since I've not seen git-annex hang when running git like that, I guess
git probably does something that avoids hanging similarly. Still, fixed
the same problem in Utility.Gpg too.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2024-01-10 17:31:58 -04:00
parent 60366e73e0
commit 790600f7b2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 2 additions and 0 deletions

View file

@ -163,6 +163,7 @@ feedRead cmd params passphrase feeder reader = do
let setup = liftIO $ do
-- pipe the passphrase into gpg on a fd
(frompipe, topipe) <- System.Posix.IO.createPipe
setFdOption topipe CloseOnExec True
toh <- fdToHandle topipe
t <- async $ do
B.hPutStr toh (passphrase <> "\n")

View file

@ -133,6 +133,7 @@ feedRead cmd subcmd params password emptydirectory feeder reader = do
let setup = liftIO $ do
-- pipe the passphrase in on a fd
(frompipe, topipe) <- System.Posix.IO.createPipe
setFdOption topipe CloseOnExec True
toh <- fdToHandle topipe
t <- async $ do
B.hPutStr toh (password <> "\n")