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.
diff --git a/src/channel.c b/src/channel.c
index 073694e..be25f5e 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1016,11 +1016,9 @@
{
/* When using a pty the same FD is set on multiple parts, only
* close it when the last reference is closed. */
- if ((part == PART_IN || channel->ch_part[PART_IN].ch_fd != *fd)
- && (part == PART_OUT
- || channel->ch_part[PART_OUT].ch_fd != *fd)
- && (part == PART_ERR
- || channel->ch_part[PART_ERR].ch_fd != *fd))
+ if ((part == PART_IN || channel->CH_IN_FD != *fd)
+ && (part == PART_OUT || channel->CH_OUT_FD != *fd)
+ && (part == PART_ERR || channel->CH_ERR_FD != *fd))
fd_close(*fd);
}
*fd = INVALID_FD;
@@ -4592,6 +4590,7 @@
}
mch_clear_job(job);
+ vim_free(job->jv_tty_name);
vim_free(job->jv_stoponexit);
free_callback(job->jv_exit_cb, job->jv_exit_partial);
}
@@ -5164,6 +5163,8 @@
nr = job->jv_proc_info.dwProcessId;
#endif
dict_add_nr_str(dict, "process", nr, NULL);
+ dict_add_nr_str(dict, "tty", 0L,
+ job->jv_tty_name != NULL ? job->jv_tty_name : (char_u *)"");
dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL);
dict_add_nr_str(dict, "exit_cb", 0L, job->jv_exit_cb);