Mercurial > vim
comparison src/os_unix.c @ 8408:2f1a63269250 v7.4.1495
commit https://github.com/vim/vim/commit/802d559431e6003a46c7f19628213b7cec8ba6d0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 5 22:05:27 2016 +0100
patch 7.4.1495
Problem: Compiler warnings when building on Unix with the job feature but
without the channel feature.
Solution: Move #ifdefs. (Dominique Pelle)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 05 Mar 2016 22:15:04 +0100 |
parents | 3b9a306724ec |
children | 800423dbc260 |
comparison
equal
deleted
inserted
replaced
8407:567418b69d4b | 8408:2f1a63269250 |
---|---|
5035 #endif /* USE_SYSTEM */ | 5035 #endif /* USE_SYSTEM */ |
5036 } | 5036 } |
5037 | 5037 |
5038 #if defined(FEAT_JOB) || defined(PROTO) | 5038 #if defined(FEAT_JOB) || defined(PROTO) |
5039 void | 5039 void |
5040 mch_start_job(char **argv, job_T *job, jobopt_T *options) | 5040 mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED) |
5041 { | 5041 { |
5042 pid_t pid; | 5042 pid_t pid; |
5043 # ifdef FEAT_CHANNEL | |
5043 int fd_in[2]; /* for stdin */ | 5044 int fd_in[2]; /* for stdin */ |
5044 int fd_out[2]; /* for stdout */ | 5045 int fd_out[2]; /* for stdout */ |
5045 int fd_err[2]; /* for stderr */ | 5046 int fd_err[2]; /* for stderr */ |
5046 # ifdef FEAT_CHANNEL | |
5047 channel_T *channel = NULL; | 5047 channel_T *channel = NULL; |
5048 int use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT; | 5048 int use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT; |
5049 #endif | |
5050 | 5049 |
5051 /* default is to fail */ | 5050 /* default is to fail */ |
5052 job->jv_status = JOB_FAILED; | 5051 job->jv_status = JOB_FAILED; |
5053 fd_in[0] = -1; | 5052 fd_in[0] = -1; |
5054 fd_out[0] = -1; | 5053 fd_out[0] = -1; |
5055 fd_err[0] = -1; | 5054 fd_err[0] = -1; |
5056 | 5055 |
5057 /* TODO: without the channel feature connect the child to /dev/null? */ | 5056 /* TODO: without the channel feature connect the child to /dev/null? */ |
5058 # ifdef FEAT_CHANNEL | |
5059 /* Open pipes for stdin, stdout, stderr. */ | 5057 /* Open pipes for stdin, stdout, stderr. */ |
5060 if (pipe(fd_in) < 0 || pipe(fd_out) < 0 | 5058 if (pipe(fd_in) < 0 || pipe(fd_out) < 0 |
5061 || (!use_out_for_err && pipe(fd_err) < 0)) | 5059 || (!use_out_for_err && pipe(fd_err) < 0)) |
5062 goto failed; | 5060 goto failed; |
5063 | 5061 |
5112 /* set up stdout for the child */ | 5110 /* set up stdout for the child */ |
5113 close(fd_out[0]); | 5111 close(fd_out[0]); |
5114 close(1); | 5112 close(1); |
5115 ignored = dup(fd_out[1]); | 5113 ignored = dup(fd_out[1]); |
5116 close(fd_out[1]); | 5114 close(fd_out[1]); |
5117 | |
5118 # endif | 5115 # endif |
5119 | 5116 |
5120 /* See above for type of argv. */ | 5117 /* See above for type of argv. */ |
5121 execvp(argv[0], argv); | 5118 execvp(argv[0], argv); |
5122 | 5119 |
5129 job->jv_status = JOB_STARTED; | 5126 job->jv_status = JOB_STARTED; |
5130 # ifdef FEAT_CHANNEL | 5127 # ifdef FEAT_CHANNEL |
5131 job->jv_channel = channel; | 5128 job->jv_channel = channel; |
5132 # endif | 5129 # endif |
5133 | 5130 |
5131 # ifdef FEAT_CHANNEL | |
5134 /* child stdin, stdout and stderr */ | 5132 /* child stdin, stdout and stderr */ |
5135 close(fd_in[0]); | 5133 close(fd_in[0]); |
5136 close(fd_out[1]); | 5134 close(fd_out[1]); |
5137 # ifdef FEAT_CHANNEL | |
5138 if (!use_out_for_err) | 5135 if (!use_out_for_err) |
5139 # endif | |
5140 close(fd_err[1]); | 5136 close(fd_err[1]); |
5141 # ifdef FEAT_CHANNEL | |
5142 channel_set_pipes(channel, fd_in[1], fd_out[0], | 5137 channel_set_pipes(channel, fd_in[1], fd_out[0], |
5143 use_out_for_err ? INVALID_FD : fd_err[0]); | 5138 use_out_for_err ? INVALID_FD : fd_err[0]); |
5144 channel_set_job(channel, job, options); | 5139 channel_set_job(channel, job, options); |
5145 # ifdef FEAT_GUI | 5140 # ifdef FEAT_GUI |
5146 channel_gui_register(channel); | 5141 channel_gui_register(channel); |
5147 # endif | 5142 # endif |
5148 # endif | 5143 # endif |
5149 | 5144 |
5150 return; | 5145 return; |
5151 | 5146 |
5152 failed: | 5147 failed: ; |
5153 # ifdef FEAT_CHANNEL | 5148 # ifdef FEAT_CHANNEL |
5154 if (channel != NULL) | 5149 if (channel != NULL) |
5155 channel_free(channel); | 5150 channel_free(channel); |
5156 # endif | |
5157 if (fd_in[0] >= 0) | 5151 if (fd_in[0] >= 0) |
5158 { | 5152 { |
5159 close(fd_in[0]); | 5153 close(fd_in[0]); |
5160 close(fd_in[1]); | 5154 close(fd_in[1]); |
5161 } | 5155 } |
5167 if (fd_err[0] >= 0) | 5161 if (fd_err[0] >= 0) |
5168 { | 5162 { |
5169 close(fd_err[0]); | 5163 close(fd_err[0]); |
5170 close(fd_err[1]); | 5164 close(fd_err[1]); |
5171 } | 5165 } |
5166 # endif | |
5172 } | 5167 } |
5173 | 5168 |
5174 char * | 5169 char * |
5175 mch_job_status(job_T *job) | 5170 mch_job_status(job_T *job) |
5176 { | 5171 { |