From e9d961f0b1debed82fc004d6631ffe6adff7c19f Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 24 Sep 2023 22:30:34 -0700 Subject: [PATCH] Check for process liveness before calling 'process-send-string' in Eshell In other words, seek permission instead of asking for forgiveness (bug#66186). * lisp/eshell/esh-io.el (eshell-output-object-to-target): Check 'process-live-p' first. --- lisp/eshell/esh-io.el | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index cd0cee6e21d..668ff13b825 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -644,15 +644,10 @@ eshell-output-object-to-target "Output OBJECT to the process TARGET." (unless (stringp object) (setq object (eshell-stringify object))) - (condition-case err + (if (process-live-p target) (process-send-string target object) - (error - ;; If `process-send-string' raises an error and the process has - ;; finished, treat it as a broken pipe. Otherwise, just - ;; re-throw the signal. - (if (process-live-p target) - (signal (car err) (cdr err)) - (signal 'eshell-pipe-broken (list target))))) + ;; If the process is already dead, treat that as a broken pipe. + (signal 'eshell-pipe-broken (list target))) object) (cl-defmethod eshell-output-object-to-target (object -- 2.25.1