patch 8.0.0744: terminal window does not use a pty

Problem:    A terminal window uses pipes instead of a pty.
Solution:   Add pty support.
diff --git a/src/channel.c b/src/channel.c
index 141bc5f..7af19b0 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1013,7 +1013,16 @@
 	if (part == PART_SOCK)
 	    sock_close(*fd);
 	else
-	    fd_close(*fd);
+	{
+	    /* 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))
+		fd_close(*fd);
+	}
 	*fd = INVALID_FD;
 
 	channel->ch_to_be_closed &= ~(1 << part);
@@ -4280,6 +4289,12 @@
 		opt->jo_io_name[part] =
 		       get_tv_string_buf_chk(item, opt->jo_io_name_buf[part]);
 	    }
+	    else if (STRCMP(hi->hi_key, "pty") == 0)
+	    {
+		if (!(supported & JO_MODE))
+		    break;
+		opt->jo_pty = get_tv_number(item);
+	    }
 	    else if (STRCMP(hi->hi_key, "in_buf") == 0
 		    || STRCMP(hi->hi_key, "out_buf") == 0
 		    || STRCMP(hi->hi_key, "err_buf") == 0)
@@ -5074,10 +5089,10 @@
 	ch_logs(NULL, "Starting job: %s", (char *)ga.ga_data);
 	ga_clear(&ga);
     }
-    mch_start_job(argv, job, &opt);
+    mch_job_start(argv, job, &opt);
 #else
     ch_logs(NULL, "Starting job: %s", (char *)cmd);
-    mch_start_job((char *)cmd, job, &opt);
+    mch_job_start((char *)cmd, job, &opt);
 #endif
 
     /* If the channel is reading from a buffer, write lines now. */