diff src/os_unix.c @ 8384:764dba33605c v7.4.1484

commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 3 21:02:23 2016 +0100 patch 7.4.1484 Problem: Channel "err-io" value "out" is not supported. Solution: Connect stderr to stdout if wanted.
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Mar 2016 21:15:05 +0100
parents 45740f83b3ce
children 3b9a306724ec
line wrap: on
line diff
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5045,6 +5045,7 @@ mch_start_job(char **argv, job_T *job, j
     int		fd_err[2];	/* for stderr */
 # ifdef FEAT_CHANNEL
     channel_T	*channel = NULL;
+    int		use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT;
 #endif
 
     /* default is to fail */
@@ -5056,7 +5057,8 @@ mch_start_job(char **argv, job_T *job, j
     /* TODO: without the channel feature connect the child to /dev/null? */
 # ifdef FEAT_CHANNEL
     /* Open pipes for stdin, stdout, stderr. */
-    if ((pipe(fd_in) < 0) || (pipe(fd_out) < 0) ||(pipe(fd_err) < 0))
+    if (pipe(fd_in) < 0 || pipe(fd_out) < 0
+				    || (!use_out_for_err && pipe(fd_err) < 0))
 	goto failed;
 
     channel = add_channel();
@@ -5093,17 +5095,26 @@ mch_start_job(char **argv, job_T *job, j
 	ignored = dup(fd_in[0]);
 	close(fd_in[0]);
 
+	/* set up stderr for the child */
+	if (use_out_for_err)
+	{
+	    close(2);
+	    ignored = dup(fd_out[1]);
+	}
+	else
+	{
+	    close(fd_err[0]);
+	    close(2);
+	    ignored = dup(fd_err[1]);
+	    close(fd_err[1]);
+	}
+
 	/* set up stdout for the child */
 	close(fd_out[0]);
 	close(1);
 	ignored = dup(fd_out[1]);
 	close(fd_out[1]);
 
-	/* set up stderr for the child */
-	close(fd_err[0]);
-	close(2);
-	ignored = dup(fd_err[1]);
-	close(fd_err[1]);
 # endif
 
 	/* See above for type of argv. */
@@ -5123,9 +5134,13 @@ mch_start_job(char **argv, job_T *job, j
     /* child stdin, stdout and stderr */
     close(fd_in[0]);
     close(fd_out[1]);
-    close(fd_err[1]);
 # ifdef FEAT_CHANNEL
-    channel_set_pipes(channel, fd_in[1], fd_out[0], fd_err[0]);
+    if (!use_out_for_err)
+# endif
+	close(fd_err[1]);
+# ifdef FEAT_CHANNEL
+    channel_set_pipes(channel, fd_in[1], fd_out[0],
+				    use_out_for_err ? INVALID_FD : fd_err[0]);
     channel_set_job(channel, job);
     channel_set_options(channel, options);
 #  ifdef FEAT_GUI