diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 86ae69978f..b833657c46 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -389,7 +389,12 @@ eshell-insertion-filter (unwind-protect (condition-case nil (eshell-output-object data nil (cadr entry)) - (eshell-pipe-broken (signal-process proc 'SIGPIPE))) + (eshell-pipe-broken + ;; Note: this will trigger a broken pipe error + ;; for the process the *next* time it tries to + ;; write. We could also opportunistically send + ;; SIGPIPE here to notify the process sooner. + (process-break-pipe proc))) (setcar (nthcdr 4 entry) nil)))))))))) (defun eshell-sentinel (proc string) diff --git a/src/process.c b/src/process.c index 94cc880097..12cd395cf3 100644 --- a/src/process.c +++ b/src/process.c @@ -2297,6 +2297,16 @@ create_pty (Lisp_Object process) p->pid = -2; } +DEFUN ("process-break-pipe", Fprocess_break_up, Sprocess_break_pipe, + 1, 1, 0, + doc: /* Close the read end of the process's output pipe. */) + (register Lisp_Object process) +{ + CHECK_PROCESS (process); + close_process_fd (&XPROCESS (process)->open_fd[READ_FROM_SUBPROCESS]); + return Qnil; +} + DEFUN ("make-pipe-process", Fmake_pipe_process, Smake_pipe_process, 0, MANY, 0, doc: /* Create and return a bidirectional pipe process. @@ -8615,6 +8625,7 @@ syms_of_process (void) defsubr (&Sset_process_buffer); defsubr (&Sprocess_buffer); defsubr (&Sprocess_mark); + defsubr (&Sprocess_break_pipe); defsubr (&Sset_process_filter); defsubr (&Sprocess_filter); defsubr (&Sset_process_sentinel);