summaryrefslogtreecommitdiffstats
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-03 13:51:25 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-03 13:51:25 +0200
commit7c9aec4ac86ccc455c0859d9393253141e3f77b6 (patch)
treee03624a977c4f3d9b040a866356dbc8245036603 /src/os_unix.c
parentd8dc1799377027be622d8571545658b20042e92e (diff)
patch 8.0.0846: cannot get the name of the pty of a jobv8.0.0846
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.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 7c4b3180e5..c90ab34f62 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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. */