Subject: [PATCH 2/2] Improve thread safety of piped-process.

From: Josselin Poiret <[email-masked]>
Date: Thu, 26 May 2022 22:50:47 +0200

* libguile/posix.c (scm_piped_process): Avoid double close.
---
 libguile/posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index dc3080b3c..e134408e3 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1486,7 +1486,7 @@ scm_piped_process (SCM prog, SCM args, SCM from, SCM to)
       SCM_SYSERROR;
     }
 
-  if (reading)
+  if (reading && !(writing && c2p[1] == p2c[0]))
     close (c2p[1]);
   if (writing)
     close (p2c[0]);
-- 
2.36.0