summaryrefslogtreecommitdiff
path: root/lisp/eshell/esh-io.el
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2022-02-01 19:16:00 -0800
committerLars Ingebrigtsen <larsi@gnus.org>2022-02-21 18:39:40 +0100
commit9df5e3080066341d78489f0b18eabeeccac76b0c (patch)
treeea9ac8b9c383da7c975c2a7ebb27dca45f9012f6 /lisp/eshell/esh-io.el
parent76429f4d1792b890c6fc69a5bd7a5cdef28d257a (diff)
downloademacs-9df5e3080066341d78489f0b18eabeeccac76b0c.tar.gz
emacs-9df5e3080066341d78489f0b18eabeeccac76b0c.tar.bz2
emacs-9df5e3080066341d78489f0b18eabeeccac76b0c.zip
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.
Diffstat (limited to 'lisp/eshell/esh-io.el')
-rw-r--r--lisp/eshell/esh-io.el12
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index fc1124561a5..3644c1a18b5 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -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))))