aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorJim Porter2022-07-19 21:36:54 -0700
committerJim Porter2022-08-05 17:58:54 -0700
commit4e59830bc0ab17cdbd85748b133c97837bed99e3 (patch)
tree1fc29e2e33f71d60915c2f15e52a97dd416773ed /lisp/eshell
parentd7b89ea4077d4fe677ba0577245328819ee79cdc (diff)
downloademacs-4e59830bc0ab17cdbd85748b133c97837bed99e3.tar.gz
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')
-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."
276 ;; If we're redirecting to a process (via a pipe, or process 276 ;; If we're redirecting to a process (via a pipe, or process
277 ;; redirection), send it EOF so that it knows we're finished. 277 ;; redirection), send it EOF so that it knows we're finished.
278 ((eshell-processp target) 278 ((eshell-processp target)
279 ;; According to POSIX.1-2017, section 11.1.9, sending EOF causes 279 ;; According to POSIX.1-2017, section 11.1.9, when communicating
280 ;; all bytes waiting to be read to be sent to the process 280 ;; via terminal, sending EOF causes all bytes waiting to be read
281 ;; immediately. Thus, if there are any bytes waiting, we need to 281 ;; to be sent to the process immediately. Thus, if there are any
282 ;; send EOF twice: once to flush the buffer, and a second time to 282 ;; bytes waiting, we need to send EOF twice: once to flush the
283 ;; cause the next read() to return a size of 0, indicating 283 ;; buffer, and a second time to cause the next read() to return a
284 ;; end-of-file to the reading process. However, some platforms 284 ;; size of 0, indicating end-of-file to the reading process.
285 ;; (e.g. Solaris) actually require sending a *third* EOF. Since 285 ;; However, some platforms (e.g. Solaris) actually require sending
286 ;; sending extra EOFs while the process is running shouldn't break 286 ;; a *third* EOF. Since sending extra EOFs while the process is
287 ;; anything, we'll just send the maximum we'd ever need. See 287 ;; running are a no-op, we'll just send the maximum we'd ever
288 ;; bug#56025 for further details. 288 ;; need. See bug#56025 for further details.
289 (let ((i 0)) 289 (let ((i 0)
290 (while (and (<= (cl-incf i) 3) 290 ;; Only call `process-send-eof' once if communicating via a
291 ;; pipe (in truth, this just closes the pipe).
292 (max-attempts (if (process-tty-name target 'stdin) 3 1)))
293 (while (and (<= (cl-incf i) max-attempts)
291 (eq (process-status target) 'run)) 294 (eq (process-status target) 'run))
292 (process-send-eof target)))) 295 (process-send-eof target))))
293 296