mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-11 09:20:51 +00:00
Fix another race condition when waiting for Eshell processes
When checking if the other processes in our pipeline are "alive", we also need to check whether their sentinels are finished. Otherwise, we might proceed with command evaluation while one of the other processes is still cleaning up. * lisp/eshell/esh-proc.el (eshell-process-active-p): New function... (eshell-wait-for-process) * lisp/eshell/esh-cmd.el (eshell-resume-command): ... use it.
This commit is contained in:
parent
991bf3f0f5
commit
146bd41dde
@ -1018,7 +1018,7 @@ process(es) in a cons cell like:
|
||||
;; Make sure PROC is one of our foreground processes and
|
||||
;; that all of those processes are now dead.
|
||||
(member proc eshell-last-async-procs)
|
||||
(not (seq-some #'process-live-p eshell-last-async-procs)))
|
||||
(not (seq-some #'eshell-process-active-p eshell-last-async-procs)))
|
||||
(eshell-resume-eval)))
|
||||
|
||||
(defun eshell-resume-eval ()
|
||||
|
@ -157,15 +157,21 @@ The signals which will cause this to happen are matched by
|
||||
(declare-function eshell-reset "esh-mode" (&optional no-hooks))
|
||||
(eshell-reset)))
|
||||
|
||||
(defun eshell-process-active-p (process)
|
||||
"Return non-nil if PROCESS is active.
|
||||
This is like `process-live-p', but additionally checks whether
|
||||
`eshell-sentinel' has finished all of its work yet."
|
||||
(or (process-live-p process)
|
||||
;; 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 process :eshell-handles)))
|
||||
|
||||
(defun eshell-wait-for-process (&rest procs)
|
||||
"Wait until PROCS have successfully completed."
|
||||
(dolist (proc procs)
|
||||
(when (eshell-processp 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))
|
||||
(while (eshell-process-active-p proc)
|
||||
(when (input-pending-p)
|
||||
(discard-input))
|
||||
(sit-for eshell-process-wait-seconds
|
||||
|
Loading…
Reference in New Issue
Block a user