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.
diff --git a/src/os_unix.c b/src/os_unix.c
index de0bb31..f77debc 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5466,7 +5466,7 @@
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 @@
}
#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.