diff src/channel.c @ 10052:c1ba49441c90 v7.4.2297

commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 1 14:35:22 2016 +0200 patch 7.4.2297 Problem: When starting a job that reads from a buffer and reaching the end, the job hangs. Solution: Close the pipe or socket when all lines were read.
author Christian Brabandt <cb@256bit.org>
date Thu, 01 Sep 2016 14:45:06 +0200
parents 4aead6a9b7a9
children d4b7232fc63a
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -1424,11 +1424,14 @@ channel_write_in(channel_T *channel)
 	ch_logn(channel, "written %d lines to channel", written);
 
     in_part->ch_buf_top = lnum;
-    if (lnum > buf->b_ml.ml_line_count)
+    if (lnum > buf->b_ml.ml_line_count || lnum > in_part->ch_buf_bot)
     {
 	/* Writing is done, no longer need the buffer. */
 	in_part->ch_bufref.br_buf = NULL;
 	ch_log(channel, "Finished writing all lines to channel");
+
+	/* Close the pipe/socket, so that the other side gets EOF. */
+	may_close_part(&channel->CH_IN_FD);
     }
     else
 	ch_logn(channel, "Still %d more lines to write",