[PATCH] vi: discover window size even on serial consoles

Rob Landley rob at landley.net
Thu Apr 22 04:39:05 UTC 2010


On Tuesday 20 April 2010 02:32:07 Denys Vlasenko wrote:
> On Tue, Apr 20, 2010 at 12:15 AM, Rob Landley <rob at landley.net> wrote:
> > On Monday 19 April 2010 20:39:14 Denys Vlasenko wrote:
> >> On Mon, Apr 19, 2010 at 7:21 PM, Rob Landley <rob at landley.net> wrote:
> >> > You already have CONFIG_FEATURE_EDITING_ASK_TERMINAL, I expect vi
> >> > should just use that config symbol instead of creating another one
> >> > that does the same thing just for it.  (And is it "editing"?  What if
> >> > top wants to do this?)
> >>
> >> CONFIG_FEATURE_EDITING_foo is only about read_line_input().
> >> vi does not use that function, thus it should depend on such symbols.
> >> Also, I consider CONFIG_FEATURE_EDITING_ASK_TERMINAL hack unreliable
> >> - it has known failure modes. Thus I want to make it possible
> >> to turn it off even if we want vi to use a similar trick.
> >
> > What are the known failure modes?
>
> Large comment in ask_terminal() explains it.

        /* Problem: if there is buffered input on stdin,
         * the response will be delivered later,
         * possibly to an unsuspecting application.

Which is why

  A) you emit it when there's no input pending, so "cat stuff | sh" would 
theoretically never trigger it.  (In the case of line input, if they've 
started typing anything before the prompt has finished displaying, just don't 
probe this time around.)
  B) you handle the replies asynchronously as part of your normal escape key 
processing that recognizes "cursor left" and such, so it doesn't matter when 
the replies come in.

Admittedly a specific narrow race condition in the pattern of user input (not 
the cat stuff above which would be inputting data while the prompt printed) can 
type something like "x" "enter" and have a spurious escape sequence fed to x.  
But the same is true if you typo a key like "cursor up" after hitting enter.  
Not the end of the world.

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds


More information about the busybox mailing list