Mercurial > vim
comparison src/os_unix.c @ 10019:782a8070c3a6 v7.4.2282
commit https://github.com/vim/vim/commit/0abe0522d0e52b50c6eab52323be558eb56fe95e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 28 16:53:12 2016 +0200
patch 7.4.2282
Problem: When a child process is very fast waiting 10 msec for it is
noticeable. (Ramel Eshed)
Solution: Start waiting for 1 msec and gradually increase.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 28 Aug 2016 17:00:07 +0200 |
parents | bff8a09016a5 |
children | 4aead6a9b7a9 |
comparison
equal
deleted
inserted
replaced
10018:04d91be62075 | 10019:782a8070c3a6 |
---|---|
3932 */ | 3932 */ |
3933 static pid_t | 3933 static pid_t |
3934 wait4pid(pid_t child, waitstatus *status) | 3934 wait4pid(pid_t child, waitstatus *status) |
3935 { | 3935 { |
3936 pid_t wait_pid = 0; | 3936 pid_t wait_pid = 0; |
3937 long delay_msec = 1; | |
3937 | 3938 |
3938 while (wait_pid != child) | 3939 while (wait_pid != child) |
3939 { | 3940 { |
3940 /* When compiled with Python threads are probably used, in which case | 3941 /* When compiled with Python threads are probably used, in which case |
3941 * wait() sometimes hangs for no obvious reason. Use waitpid() | 3942 * wait() sometimes hangs for no obvious reason. Use waitpid() |
3946 # else | 3947 # else |
3947 wait_pid = waitpid(child, status, WNOHANG); | 3948 wait_pid = waitpid(child, status, WNOHANG); |
3948 # endif | 3949 # endif |
3949 if (wait_pid == 0) | 3950 if (wait_pid == 0) |
3950 { | 3951 { |
3951 /* Wait for 10 msec before trying again. */ | 3952 /* Wait for 1 to 10 msec before trying again. */ |
3952 mch_delay(10L, TRUE); | 3953 mch_delay(delay_msec, TRUE); |
3954 if (++delay_msec > 10) | |
3955 delay_msec = 10; | |
3953 continue; | 3956 continue; |
3954 } | 3957 } |
3955 if (wait_pid <= 0 | 3958 if (wait_pid <= 0 |
3956 # ifdef ECHILD | 3959 # ifdef ECHILD |
3957 && errno == ECHILD | 3960 && errno == ECHILD |
4927 close(fromshell_fd); | 4930 close(fromshell_fd); |
4928 } | 4931 } |
4929 # if defined(FEAT_XCLIPBOARD) && defined(FEAT_X11) | 4932 # if defined(FEAT_XCLIPBOARD) && defined(FEAT_X11) |
4930 else | 4933 else |
4931 { | 4934 { |
4935 long delay_msec = 1; | |
4936 | |
4932 /* | 4937 /* |
4933 * Similar to the loop above, but only handle X events, no | 4938 * Similar to the loop above, but only handle X events, no |
4934 * I/O. | 4939 * I/O. |
4935 */ | 4940 */ |
4936 for (;;) | 4941 for (;;) |
4959 } | 4964 } |
4960 | 4965 |
4961 /* Handle any X events, e.g. serving the clipboard. */ | 4966 /* Handle any X events, e.g. serving the clipboard. */ |
4962 clip_update(); | 4967 clip_update(); |
4963 | 4968 |
4964 mch_delay(10L, TRUE); | 4969 /* Wait for 1 to 10 msec. 1 is faster but gives the child |
4970 * less time. */ | |
4971 mch_delay(delay_msec, TRUE); | |
4972 if (++delay_msec > 10) | |
4973 delay_msec = 10; | |
4965 } | 4974 } |
4966 } | 4975 } |
4967 # endif | 4976 # endif |
4968 | 4977 |
4969 /* | 4978 /* |