diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-07-19 21:36:54 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2022-08-05 17:58:54 -0700 |
commit | 4e59830bc0ab17cdbd85748b133c97837bed99e3 (patch) | |
tree | 1fc29e2e33f71d60915c2f15e52a97dd416773ed /src/process.c | |
parent | d7b89ea4077d4fe677ba0577245328819ee79cdc (diff) | |
download | emacs-4e59830bc0ab17cdbd85748b133c97837bed99e3.tar.gz |
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 'src/process.c')
-rw-r--r-- | src/process.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/process.c b/src/process.c index 68dbd8b68bd..23479c06194 100644 --- a/src/process.c +++ b/src/process.c @@ -1243,14 +1243,31 @@ or t (process is stopped). */) return XPROCESS (process)->command; } -DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, +DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 2, 0, doc: /* Return the name of the terminal PROCESS uses, or nil if none. This is the terminal that the process itself reads and writes on, -not the name of the pty that Emacs uses to talk with that terminal. */) - (register Lisp_Object process) +not the name of the pty that Emacs uses to talk with that terminal. + +If STREAM is nil, return the terminal name if any of PROCESS's +standard streams use a terminal for communication. If STREAM is one +of `stdin', `stdout', or `stderr', return the name of the terminal +PROCESS uses for that stream specifically, or nil if that stream +communicates via a pipe. */) + (register Lisp_Object process, Lisp_Object stream) { CHECK_PROCESS (process); - return XPROCESS (process)->tty_name; + register struct Lisp_Process *p = XPROCESS (process); + + if (NILP (stream)) + return p->tty_name; + else if (EQ (stream, Qstdin)) + return p->pty_in ? p->tty_name : Qnil; + else if (EQ (stream, Qstdout)) + return p->pty_out ? p->tty_name : Qnil; + else if (EQ (stream, Qstderr)) + return p->pty_out && NILP (p->stderrproc) ? p->tty_name : Qnil; + else + signal_error ("Unknown stream", stream); } static void |