Mercurial > vim
diff src/os_unix.c @ 8761:f8707ec9efe4 v7.4.1669
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 28 19:16:20 2016 +0200
patch 7.4.1669
Problem: When writing buffer lines to a pipe Vim may block.
Solution: Avoid blocking, write more lines later.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 28 Mar 2016 19:30:05 +0200 |
parents | a35b596cd7ac |
children | 210e767296d9 |
line wrap: on
line diff
--- a/src/os_unix.c +++ b/src/os_unix.c @@ -5539,7 +5539,8 @@ RealWaitForChar(int fd, long msec, int * # endif #endif #ifndef HAVE_SELECT - struct pollfd fds[6 + MAX_OPEN_CHANNELS]; + /* each channel may use in, out and err */ + struct pollfd fds[6 + 3 * MAX_OPEN_CHANNELS]; int nfd; # ifdef FEAT_XCLIPBOARD int xterm_idx = -1; @@ -5652,7 +5653,7 @@ RealWaitForChar(int fd, long msec, int * struct timeval tv; struct timeval *tvp; - fd_set rfds, efds; + fd_set rfds, wfds, efds; int maxfd; long towait = msec; @@ -5685,6 +5686,7 @@ RealWaitForChar(int fd, long msec, int * */ select_eintr: FD_ZERO(&rfds); + FD_ZERO(&wfds); FD_ZERO(&efds); FD_SET(fd, &rfds); # if !defined(__QNX__) && !defined(__CYGWIN32__) @@ -5725,10 +5727,10 @@ select_eintr: } # endif # ifdef FEAT_JOB_CHANNEL - maxfd = channel_select_setup(maxfd, &rfds); -# endif - - ret = select(maxfd + 1, &rfds, NULL, &efds, tvp); + maxfd = channel_select_setup(maxfd, &rfds, &wfds); +# endif + + ret = select(maxfd + 1, &rfds, &wfds, &efds, tvp); result = ret > 0 && FD_ISSET(fd, &rfds); if (result) --ret; @@ -5810,7 +5812,7 @@ select_eintr: # endif #ifdef FEAT_JOB_CHANNEL if (ret > 0) - ret = channel_select_check(ret, &rfds); + ret = channel_select_check(ret, &rfds, &wfds); #endif #endif /* HAVE_SELECT */