diff options
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). */) | |||
| 1243 | return XPROCESS (process)->command; | 1243 | return XPROCESS (process)->command; |
| 1244 | } | 1244 | } |
| 1245 | 1245 | ||
| 1246 | DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, | 1246 | DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 2, 0, |
| 1247 | doc: /* Return the name of the terminal PROCESS uses, or nil if none. | 1247 | doc: /* Return the name of the terminal PROCESS uses, or nil if none. |
| 1248 | This is the terminal that the process itself reads and writes on, | 1248 | This is the terminal that the process itself reads and writes on, |
| 1249 | not the name of the pty that Emacs uses to talk with that terminal. */) | 1249 | not the name of the pty that Emacs uses to talk with that terminal. |
| 1250 | (register Lisp_Object process) | 1250 | |
| 1251 | If STREAM is nil, return the terminal name if any of PROCESS's | ||
| 1252 | standard streams use a terminal for communication. If STREAM is one | ||
| 1253 | of `stdin', `stdout', or `stderr', return the name of the terminal | ||
| 1254 | PROCESS uses for that stream specifically, or nil if that stream | ||
| 1255 | communicates via a pipe. */) | ||
| 1256 | (register Lisp_Object process, Lisp_Object stream) | ||
| 1251 | { | 1257 | { |
| 1252 | CHECK_PROCESS (process); | 1258 | CHECK_PROCESS (process); |
| 1253 | return XPROCESS (process)->tty_name; | 1259 | register struct Lisp_Process *p = XPROCESS (process); |
| 1260 | |||
| 1261 | if (NILP (stream)) | ||
| 1262 | return p->tty_name; | ||
| 1263 | else if (EQ (stream, Qstdin)) | ||
| 1264 | return p->pty_in ? p->tty_name : Qnil; | ||
| 1265 | else if (EQ (stream, Qstdout)) | ||
| 1266 | return p->pty_out ? p->tty_name : Qnil; | ||
| 1267 | else if (EQ (stream, Qstderr)) | ||
| 1268 | return p->pty_out && NILP (p->stderrproc) ? p->tty_name : Qnil; | ||
| 1269 | else | ||
| 1270 | signal_error ("Unknown stream", stream); | ||
| 1254 | } | 1271 | } |
| 1255 | 1272 | ||
| 1256 | static void | 1273 | static void |