Subject: Re: bug#65590: 29.0.50; esh-var-test/interp-concat-cmd fails on macOS

From: Jim Porter <[email-masked]>
Date: Wed, 13 Sep 2023 11:54:00 -0700

On 9/13/2023 9:10 AM, Stefan Kangas wrote:
> Sorry for the slow turnaround time.
> 
> I'm currently seeing these test failures on master: [snip]
Thanks for the logs. Could you try the attached patch to see if it 
improves things?

From 26b8f18dbff1ccbf0d6c91b7208cb0a4c6d73e4c Mon Sep 17 00:00:00 2001
From: Jim Porter <[email-masked]>
Date: Wed, 13 Sep 2023 11:50:39 -0700
Subject: [PATCH] When waiting for processes in Eshell, wait until all the I/O
 is complete

* lisp/eshell/esh-proc.el (eshell-sentinel): Set ':eshell-handles' to
nil when finished with I/O.
(eshell-wait-for-process): Wait until ':eshell-handles' is nil.
---
 lisp/eshell/esh-proc.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 5df68947ec2..afd0ed80132 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -161,7 +161,11 @@ eshell-wait-for-process
   "Wait until PROCS have successfully completed."
   (dolist (proc procs)
     (when (eshell-processp proc)
-      (while (process-live-p proc)
+      (while (or (process-live-p proc)
+                 ;; If we have handles, this is an Eshell-managed
+                 ;; process.  Wait until we're 100% done and have
+                 ;; cleared out the handles (see `eshell-sentinel').
+                 (process-get proc :eshell-handles))
         (when (input-pending-p)
           (discard-input))
         (sit-for eshell-process-wait-seconds
@@ -530,6 +534,9 @@ eshell-sentinel
                            status
                            (when status (list 'quote (= status 0)))
                            handles)
+                          ;; Clear the handles to mark that we're 100%
+                          ;; finished with the I/O for this process.
+                          (process-put proc :eshell-handles nil)
                           (eshell-debug-command
                            'process
                            (format-message
-- 
2.25.1