0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0846: cannot get the name of the pty of a job

Problem:    Cannot get the name of the pty of a job.
Solution:   Add the "tty" entry to the job info. (Ozaki Kiichi, closes #1920)
            Add the term_gettty() function.
This commit is contained in:
Bram Moolenaar
2017-08-03 13:51:25 +02:00
parent d8dc179937
commit 7c9aec4ac8
9 changed files with 75 additions and 26 deletions

View File

@@ -4170,7 +4170,7 @@ set_default_child_environment(void)
* When successful both file descriptors are stored.
*/
static void
open_pty(int *pty_master_fd, int *pty_slave_fd)
open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **namep)
{
char *tty_name;
@@ -4190,6 +4190,8 @@ open_pty(int *pty_master_fd, int *pty_slave_fd)
close(*pty_master_fd);
*pty_master_fd = -1;
}
else if (namep != NULL)
*namep = vim_strsave((char_u *)tty_name);
}
}
#endif
@@ -4384,7 +4386,7 @@ mch_call_shell(
* If the slave can't be opened, close the master pty.
*/
if (p_guipty && !(options & (SHELL_READ|SHELL_WRITE)))
open_pty(&pty_master_fd, &pty_slave_fd);
open_pty(&pty_master_fd, &pty_slave_fd, NULL);
/*
* If not opening a pty or it didn't work, try using pipes.
*/
@@ -5189,9 +5191,9 @@ error:
mch_job_start(char **argv, job_T *job, jobopt_T *options)
{
pid_t pid;
int fd_in[2]; /* for stdin */
int fd_out[2]; /* for stdout */
int fd_err[2]; /* for stderr */
int fd_in[2] = {-1, -1}; /* for stdin */
int fd_out[2] = {-1, -1}; /* for stdout */
int fd_err[2] = {-1, -1}; /* for stderr */
int pty_master_fd = -1;
int pty_slave_fd = -1;
channel_T *channel = NULL;
@@ -5209,15 +5211,9 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
/* default is to fail */
job->jv_status = JOB_FAILED;
fd_in[0] = -1;
fd_in[1] = -1;
fd_out[0] = -1;
fd_out[1] = -1;
fd_err[0] = -1;
fd_err[1] = -1;
if (options->jo_pty)
open_pty(&pty_master_fd, &pty_slave_fd);
open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_name);
/* TODO: without the channel feature connect the child to /dev/null? */
/* Open pipes for stdin, stdout, stderr. */