1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Send SIGPIPE to external Eshell processes if their output target closes

* lisp/eshell/esh-io.el (eshell-pipe-broken): New error.
(eshell-output-object-to-target): Signal 'eshell-pipe-broken' if the
target is an exited/signaled process.

* lisp/eshell/esh-proc.el (eshell-insertion-filter): Handle
'eshell-pipe-broken'.

* test/lisp/eshell/esh-proc-tests.el: New test.
This commit is contained in:
Jim Porter 2022-02-01 19:16:00 -08:00 committed by Lars Ingebrigtsen
parent 76429f4d17
commit 9df5e30800
4 changed files with 86 additions and 11 deletions

View file

@ -150,6 +150,8 @@ not be added to this variable."
:risky t
:group 'eshell-io)
(define-error 'eshell-pipe-broken "Pipe broken")
;;; Internal Variables:
(defvar eshell-current-handles nil)
@ -481,10 +483,12 @@ Returns what was actually sent, or nil if nothing was sent."
(goto-char target))))))
((eshell-processp target)
(when (eq (process-status target) 'run)
(unless (stringp object)
(setq object (eshell-stringify object)))
(process-send-string target object)))
(unless (stringp object)
(setq object (eshell-stringify object)))
(condition-case nil
(process-send-string target object)
;; If `process-send-string' raises an error, treat it as a broken pipe.
(error (signal 'eshell-pipe-broken target))))
((consp target)
(apply (car target) object (cdr target))))