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

patch 8.0.1000: cannot open a terminal without running a job in it

Problem:    Cannot open a terminal without running a job in it.
Solution:   Make ":terminal NONE" open a terminal with a pty.
This commit is contained in:
Bram Moolenaar
2017-08-26 22:02:51 +02:00
parent dde81312b0
commit 13ebb03e75
10 changed files with 140 additions and 30 deletions

View File

@@ -5466,7 +5466,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
job->jv_channel = channel; /* ch_refcount was set above */
if (pty_master_fd >= 0)
close(pty_slave_fd); /* duped above */
close(pty_slave_fd); /* not used in the parent */
/* close child stdin, stdout and stderr */
if (!use_file_for_in && fd_in[0] >= 0)
close(fd_in[0]);
@@ -5669,6 +5669,29 @@ mch_clear_job(job_T *job)
}
#endif
#if defined(FEAT_TERMINAL) || defined(PROTO)
int
mch_create_pty_channel(job_T *job, jobopt_T *options)
{
int pty_master_fd = -1;
int pty_slave_fd = -1;
channel_T *channel;
open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_name);
close(pty_slave_fd);
channel = add_channel();
if (channel == NULL)
return FAIL;
job->jv_channel = channel; /* ch_refcount was set by add_channel() */
channel->ch_keep_open = TRUE;
channel_set_pipes(channel, pty_master_fd, pty_master_fd, pty_master_fd);
channel_set_job(channel, job, options);
return OK;
}
#endif
/*
* Check for CTRL-C typed by reading all available characters.
* In cooked mode we should get SIGINT, no need to check.