From 790600f7b2303bb7b201975598a80fb4672aa391 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 10 Jan 2024 17:31:58 -0400 Subject: [PATCH] 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 --- Utility/Gpg.hs | 1 + Utility/StatelessOpenPGP.hs | 1 + 2 files changed, 2 insertions(+) diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs index 54521fbedf..2ef077990f 100644 --- a/Utility/Gpg.hs +++ b/Utility/Gpg.hs @@ -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") diff --git a/Utility/StatelessOpenPGP.hs b/Utility/StatelessOpenPGP.hs index dfee3ec3c5..73e3746a3a 100644 --- a/Utility/StatelessOpenPGP.hs +++ b/Utility/StatelessOpenPGP.hs @@ -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") -- 2.30.2