summaryrefslogtreecommitdiff
path: root/lisp/eshell/esh-io.el
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2022-07-19 21:36:54 -0700
committerJim Porter <jporterbugs@gmail.com>2022-08-05 17:58:54 -0700
commit4e59830bc0ab17cdbd85748b133c97837bed99e3 (patch)
tree1fc29e2e33f71d60915c2f15e52a97dd416773ed /lisp/eshell/esh-io.el
parentd7b89ea4077d4fe677ba0577245328819ee79cdc (diff)
downloademacs-4e59830bc0ab17cdbd85748b133c97837bed99e3.tar.gz
emacs-4e59830bc0ab17cdbd85748b133c97837bed99e3.tar.bz2
emacs-4e59830bc0ab17cdbd85748b133c97837bed99e3.zip
Add STREAM argument to 'process-tty-name'
* src/process.c (process-tty-name): Add STREAM argument. * lisp/eshell/esh-io.el (eshell-close-target): Only call 'process-send-eof' once if the process's stdin is a pipe. * test/src/process-tests.el (make-process/test-connection-type): Check behavior of 'process-tty-name'. * doc/lispref/processes.texi (Process Information): Document the new argument. * etc/NEWS: Announce this change.
Diffstat (limited to 'lisp/eshell/esh-io.el')
-rw-r--r--lisp/eshell/esh-io.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index c035890ddf0..68e52a2c9c8 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -276,18 +276,21 @@ STATUS should be non-nil on successful termination of the output."
;; If we're redirecting to a process (via a pipe, or process
;; redirection), send it EOF so that it knows we're finished.
((eshell-processp target)
- ;; According to POSIX.1-2017, section 11.1.9, sending EOF causes
- ;; all bytes waiting to be read to be sent to the process
- ;; immediately. Thus, if there are any bytes waiting, we need to
- ;; send EOF twice: once to flush the buffer, and a second time to
- ;; cause the next read() to return a size of 0, indicating
- ;; end-of-file to the reading process. However, some platforms
- ;; (e.g. Solaris) actually require sending a *third* EOF. Since
- ;; sending extra EOFs while the process is running shouldn't break
- ;; anything, we'll just send the maximum we'd ever need. See
- ;; bug#56025 for further details.
- (let ((i 0))
- (while (and (<= (cl-incf i) 3)
+ ;; According to POSIX.1-2017, section 11.1.9, when communicating
+ ;; via terminal, sending EOF causes all bytes waiting to be read
+ ;; to be sent to the process immediately. Thus, if there are any
+ ;; bytes waiting, we need to send EOF twice: once to flush the
+ ;; buffer, and a second time to cause the next read() to return a
+ ;; size of 0, indicating end-of-file to the reading process.
+ ;; However, some platforms (e.g. Solaris) actually require sending
+ ;; a *third* EOF. Since sending extra EOFs while the process is
+ ;; running are a no-op, we'll just send the maximum we'd ever
+ ;; need. See bug#56025 for further details.
+ (let ((i 0)
+ ;; Only call `process-send-eof' once if communicating via a
+ ;; pipe (in truth, this just closes the pipe).
+ (max-attempts (if (process-tty-name target 'stdin) 3 1)))
+ (while (and (<= (cl-incf i) max-attempts)
(eq (process-status target) 'run))
(process-send-eof target))))