Mercurial > vim
comparison src/os_unix.c @ 8491:daebcbd87bd3 v7.4.1536
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 11 22:19:44 2016 +0100
patch 7.4.1536
Problem: Cannot re-use a channel for another job.
Solution: Add the "channel" option to job_start().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 11 Mar 2016 22:30:04 +0100 |
parents | d0717262d802 |
children | caed4b2d305f |
comparison
equal
deleted
inserted
replaced
8490:eceb3c28e179 | 8491:daebcbd87bd3 |
---|---|
5109 else if (!use_out_for_err && !use_null_for_err && pipe(fd_err) < 0) | 5109 else if (!use_out_for_err && !use_null_for_err && pipe(fd_err) < 0) |
5110 goto failed; | 5110 goto failed; |
5111 | 5111 |
5112 if (!use_null_for_in || !use_null_for_out || !use_null_for_err) | 5112 if (!use_null_for_in || !use_null_for_out || !use_null_for_err) |
5113 { | 5113 { |
5114 channel = add_channel(); | 5114 if (options->jo_set & JO_CHANNEL) |
5115 { | |
5116 channel = options->jo_channel; | |
5117 if (channel != NULL) | |
5118 ++channel->ch_refcount; | |
5119 } | |
5120 else | |
5121 channel = add_channel(); | |
5115 if (channel == NULL) | 5122 if (channel == NULL) |
5116 goto failed; | 5123 goto failed; |
5117 } | 5124 } |
5118 # endif | 5125 # endif |
5119 | 5126 |
5209 | 5216 |
5210 /* parent */ | 5217 /* parent */ |
5211 job->jv_pid = pid; | 5218 job->jv_pid = pid; |
5212 job->jv_status = JOB_STARTED; | 5219 job->jv_status = JOB_STARTED; |
5213 # ifdef FEAT_CHANNEL | 5220 # ifdef FEAT_CHANNEL |
5214 job->jv_channel = channel; | 5221 job->jv_channel = channel; /* ch_refcount was set above */ |
5215 # endif | 5222 # endif |
5216 | 5223 |
5217 # ifdef FEAT_CHANNEL | 5224 # ifdef FEAT_CHANNEL |
5218 /* child stdin, stdout and stderr */ | 5225 /* child stdin, stdout and stderr */ |
5219 if (!use_file_for_in) | 5226 if (!use_file_for_in) |
5230 use_file_for_out || use_null_for_out | 5237 use_file_for_out || use_null_for_out |
5231 ? INVALID_FD : fd_out[0], | 5238 ? INVALID_FD : fd_out[0], |
5232 use_out_for_err || use_file_for_err || use_null_for_err | 5239 use_out_for_err || use_file_for_err || use_null_for_err |
5233 ? INVALID_FD : fd_err[0]); | 5240 ? INVALID_FD : fd_err[0]); |
5234 channel_set_job(channel, job, options); | 5241 channel_set_job(channel, job, options); |
5235 # ifdef FEAT_GUI | |
5236 channel_gui_register(channel); | |
5237 # endif | |
5238 } | 5242 } |
5239 # endif | 5243 # endif |
5240 | 5244 |
5241 /* success! */ | 5245 /* success! */ |
5242 return; | 5246 return; |
5243 | 5247 |
5244 failed: ; | 5248 failed: ; |
5245 # ifdef FEAT_CHANNEL | 5249 # ifdef FEAT_CHANNEL |
5246 if (channel != NULL) | 5250 channel_unref(channel); |
5247 channel_free(channel); | |
5248 if (fd_in[0] >= 0) | 5251 if (fd_in[0] >= 0) |
5249 close(fd_in[0]); | 5252 close(fd_in[0]); |
5250 if (fd_in[1] >= 0) | 5253 if (fd_in[1] >= 0) |
5251 close(fd_in[1]); | 5254 close(fd_in[1]); |
5252 if (fd_out[0] >= 0) | 5255 if (fd_out[0] >= 0) |