diff src/channel.c @ 12393:128cd982c7b8 v8.0.1076

patch 8.0.1076: term_start() does not take callbacks commit https://github.com/vim/vim/commit/3c518400d1a51929572dd9fcf77dba94d78d7545 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 8 20:47:00 2017 +0200 patch 8.0.1076: term_start() does not take callbacks Problem: term_start() does not take callbacks. When using two terminals without a job only one is read from. A terminal without a window returns the wrong pty. Solution: Support "callback", "out_cb" and "err_cb". Fix terminal without a window. Fix reading from multiple channels.
author Christian Brabandt <cb@256bit.org>
date Fri, 08 Sep 2017 21:00:04 +0200
parents d0cf7f71b95b
children b44bd42a374e
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -3692,13 +3692,10 @@ channel_send(
 	{
 	    res = fd_write(fd, (char *)buf, len);
 #ifdef WIN32
-	    if (channel->ch_named_pipe)
+	    if (channel->ch_named_pipe && res < 0)
 	    {
-		if (res < 0)
-		{
-		    DisconnectNamedPipe((HANDLE)fd);
-		    ConnectNamedPipe((HANDLE)fd, NULL);
-		}
+		DisconnectNamedPipe((HANDLE)fd);
+		ConnectNamedPipe((HANDLE)fd, NULL);
 	    }
 #endif
 
@@ -4084,6 +4081,7 @@ channel_select_check(int ret_in, void *r
 	    if (ret > 0 && fd != INVALID_FD && FD_ISSET(fd, rfds))
 	    {
 		channel_read(channel, part, "channel_select_check");
+		FD_CLR(fd, rfds);
 		--ret;
 	    }
 	}
@@ -4093,6 +4091,7 @@ channel_select_check(int ret_in, void *r
 					    && FD_ISSET(in_part->ch_fd, wfds))
 	{
 	    channel_write_input(channel);
+	    FD_CLR(in_part->ch_fd, wfds);
 	    --ret;
 	}
     }