BSD vs. SVR4 typehead flush after tty mode change

Keith Gabryelski ag at cbmvax.commodore.com
Tue Oct 16 15:30:49 AEST 1990


In article <4191 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
>>It sems to me that a bug was introduced in the kernel solely in order
>>to avoid fixing the C shell, which is clearly screwed up in its input
>>handling.  In interactive command-line editing mode, a shell should
>>read() only 1 character at a time.
>
>I won't defend the unnatural acts the C shell engages in to implement
>"filec",
>
>BUT
>
>that's not *the* problem with switching modes, it's just the most
>*obvious* one.
>
>Consider a more vanilla shell, one that runs in cooked mode.  You type
>some characters while exiting some program that runs in uncooked mode,
>those characters being typed while still in uncooked mode.  As such,
>they probably went upstream immediately and are sitting at the stream
>head.

If I am not mistaken I remember noting this same problem with
switching from non-canonized processing to canonized processing under
the old (non streams) tty subsystem.  Ie, this is not a new problem.

It also seems to me that flushing the stream when ICANON is turned
on may fix this problem for csh, but breaks typeahead (for programs
that go in an out of ICANON) and breaks termio (flushing on TCSETS).

Try (while in vi).

	:!sleep 10
	:!echo foo
	:!echo bar
	:!echo baz


Pax, Keith



More information about the Comp.unix.questions mailing list