Solaris (and maybe other SunOS distributions) have odd select() syscall behavior on tty,
and it affects input-waiting of vim.
[example]
------
while 1
let c = getchar(0)
if c != 0
break
endif
sleep 20m
if another_condition()
break
endif
endwhile
------
This script waits user input or establishment of another condition, otherwise does sleeping.
Actially it checks input by select() syscall in 2 places; in getchar(0) and end of sleep.
* in getchar(0), select() is called with tty non-canonical mode (TMODE_RAW)
* in sleep, select() is called with tty canonical mode (TMODE_SLEEP)
That is;
------
select() [non-canon] ... (a)
(20ms) ... (b)
select() [canon] ... (c)
(back to top-of-loop)
select() [non-canon] ... (a')
...
------
On linux and mac (maybe *bsd):
input during (a): detected by select(a) and breaks a loop instantly
input during (b)~(c): not detected by select(c), and detected by select(a') and breaks a loop
That is, input during canon-mode is detected at non-canon-mode.
On solaris:
input during (a): detected by select(a) and breaks a loop instantly
input during (b)~(c): not detected by either select(c) or select(a') (unless input <CR>)
That is, input during canon-mode is *NOT* detected at non-canon-mode,
so breaking-loop needs input during (a) or input <CR> to finish line-buffering (or, in this case, establish another_condition).
# input during (b)~(c) is retained, not diacarded.
# example:
# (b)~(c) <- input "123"
# (a') <- input "4"
# select(a') detects input and read() reads "1234" from tty.
[patch]
Drop ICANON flag (and set VMIN to 1 VTIME to 0) at TMODE_SLEEP
https://gist.github.com/ichizok/acae1b5431a639108dd8cf2768823dc2
# This patch is part of https://groups.google.com/forum/#!msg/vim_dev/8ciQGDB-0Og/NiaJYwQHKF8J
Thank you.
- Ozaki Kiichi
I think because the number of vim users (using a lot plugins) on solaris is far less than on linux, mac, win, so maybe this behavior has received less attention.
> Since the patch is for Solaris (or perhaps SysV kind of Unix?), should
> we add this inside an #ifdef? Or would it be OK to do the same on all
> systems?
It is, as far as I found out, on only solaris problem.
But I think there is no need to keep ICANON on TMODE_SLEEP and we can apply changes to all systems.