comparison src/os_unix.c @ 8845:210e767296d9 v7.4.1710

commit https://github.com/vim/vim/commit/17fe5e1aecbeff5ca4b2a821ede9badd5dddae59 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 4 22:03:08 2016 +0200 patch 7.4.1710 Problem: Not all output of an external command is read. Solution: Avoid timing out when the process has exited. (closes https://github.com/vim/vim/issues/681)
author Christian Brabandt <cb@256bit.org>
date Mon, 04 Apr 2016 22:15:31 +0200
parents f8707ec9efe4
children c07caeb90a35
comparison
equal deleted inserted replaced
8844:d526a0ea94b3 8845:210e767296d9
4843 out_flush(); 4843 out_flush();
4844 if (got_int) 4844 if (got_int)
4845 break; 4845 break;
4846 4846
4847 # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) 4847 # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
4848 if (wait_pid == 0)
4848 { 4849 {
4849 struct timeval now_tv; 4850 struct timeval now_tv;
4850 long msec; 4851 long msec;
4851 4852
4852 /* Avoid that we keep looping here without 4853 /* Avoid that we keep looping here without
4853 * checking for a CTRL-C for a long time. Don't 4854 * checking for a CTRL-C for a long time. Don't
4854 * break out too often to avoid losing typeahead. */ 4855 * break out too often to avoid losing typeahead. */
4855 gettimeofday(&now_tv, NULL); 4856 gettimeofday(&now_tv, NULL);
4856 msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L 4857 msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
4857 + (now_tv.tv_usec - start_tv.tv_usec) / 1000L; 4858 + (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
4858 if (msec > 2000) 4859 if (msec > 2000)
4859 { 4860 {
4860 noread_cnt = 5; 4861 noread_cnt = 5;
4861 break; 4862 break;
4862 } 4863 }
4863 } 4864 }
4864 # endif 4865 # endif
4865 } 4866 }
4866 4867
4867 /* If we already detected the child has finished break the 4868 /* If we already detected the child has finished, continue
4868 * loop now. */ 4869 * reading output for a short while. Some text may be
4870 * buffered. */
4869 if (wait_pid == pid) 4871 if (wait_pid == pid)
4872 {
4873 if (noread_cnt < 5)
4874 continue;
4870 break; 4875 break;
4876 }
4871 4877
4872 /* 4878 /*
4873 * Check if the child still exists, before checking for 4879 * Check if the child still exists, before checking for
4874 * typed characters (otherwise we would lose typeahead). 4880 * typed characters (otherwise we would lose typeahead).
4875 */ 4881 */