avoid broken pipe zombies
authorJoey Hess <joeyh@joeyh.name>
Thu, 31 Jul 2025 18:57:51 +0000 (14:57 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 31 Jul 2025 18:57:51 +0000 (14:57 -0400)
hClose crashes if the pipe is broken, preventing waiting for the process

P2P/IO.hs

index ec1cb5437551fe7e0d0d5901866b4a4fefda9d63..956c4192c85b6487afc87441257d338ec23d9f91 100644 (file)
--- a/P2P/IO.hs
+++ b/P2P/IO.hs
@@ -162,8 +162,9 @@ connectPeer g (P2PAnnex netname address) = do
 
 closeConnection :: P2PConnection -> IO ()
 closeConnection conn = do
-       closehandle (connIhdl conn)
-       closehandle (connOhdl conn)
+       -- hClose can fail if the handle is connected to a broken pipe
+       void $ tryNonAsync $ closehandle (connIhdl conn)
+       void $ tryNonAsync $ closehandle (connOhdl conn)
        case connProcess conn of
                Nothing -> noop
                Just ph -> void $ waitForProcess ph