summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-09-06 16:27:24 +0200
committerBram Moolenaar <Bram@vim.org>2018-09-06 16:27:24 +0200
commit0b1468884a2a1c5d3442cbb7119330e307f0aa3d (patch)
treea459e23a481dc0f19bbbe4acbdc35756ed2c7efa /src/channel.c
parented5a9d661248a2160368f1b0ab3a1bf74831db04 (diff)
patch 8.1.0350: Vim may block on ch_sendraw()v8.1.0350
Problem: Vim may block on ch_sendraw() when the job is sending data back to Vim, which isn't read yet. (Nate Bosch) Solution: Add the "noblock" option to job_start(). (closes #2548)
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c
index 282340eefc..793dbaa833 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1180,6 +1180,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode;
if (opt->jo_set & JO_ERR_MODE)
channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode;
+ channel->ch_nonblock = opt->jo_noblock;
if (opt->jo_set & JO_TIMEOUT)
for (part = PART_SOCK; part < PART_COUNT; ++part)
@@ -3677,7 +3678,7 @@ channel_any_keep_open()
channel_set_nonblock(channel_T *channel, ch_part_T part)
{
chanpart_T *ch_part = &channel->ch_part[part];
- int fd = ch_part->ch_fd;
+ int fd = ch_part->ch_fd;
if (fd != INVALID_FD)
{
@@ -3722,6 +3723,9 @@ channel_send(
return FAIL;
}
+ if (channel->ch_nonblock && !ch_part->ch_nonblocking)
+ channel_set_nonblock(channel, part);
+
if (ch_log_active())
{
ch_log_lead("SEND ", channel, part);
@@ -4553,6 +4557,12 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
== FAIL)
return FAIL;
}
+ else if (STRCMP(hi->hi_key, "noblock") == 0)
+ {
+ if (!(supported & JO_MODE))
+ break;
+ opt->jo_noblock = get_tv_number(item);
+ }
else if (STRCMP(hi->hi_key, "in_io") == 0
|| STRCMP(hi->hi_key, "out_io") == 0
|| STRCMP(hi->hi_key, "err_io") == 0)