TIOCGWINSZ and busybox
Denis Vlasenko
vda.linux at googlemail.com
Sun Mar 11 11:02:08 UTC 2007
On Sunday 11 March 2007 02:25, Fischer, Matthew L (SHML - Diagnostics) wrote:
> > screen size is taken from enviroment: $LINES, $COLUMNS:
> >
> > int get_terminal_width_height(const int fd, int *width, int *height)
> > {
> > struct winsize win = { 0, 0, 0, 0 };
> > int ret = ioctl(fd, TIOCGWINSZ, &win);
> > if (height) {
> > if (!win.ws_row) {
> > char *s = getenv("LINES");
> > if (s) win.ws_row = atoi(s);
> > }
> > if (win.ws_row <= 1 || win.ws_row >= 30000)
> > win.ws_row = 24;
> > *height = (int) win.ws_row;
> > }
> > << same for COLUMNS>>
> >
> > > this is probably the resize culprit
> > > (since more appears to use these values).
> >
> > With FEATURE_RESIZE_PRINT on, what does resize print and what is its
> > exit code?
>
> I didn't see this option in our config file, so I will ask the team's
> busybox/kernel guy to either get it set or upgrade busybox so we can set
> it.
>
> I did run the resize code (not from busybox, just from regular ole'
> resize) and the ioctl fails there too (of course). "Regular" Resize
> seems to use some magic then to guess at the new row and height, but it
> seems to be correct.
What magic? Can you show 'strace -o resize' output, or better yet,
show the source of that other resize?
> > resize's exit code is a result of "set terminal size" ioctl:
> >
> > ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
> > printf(ESC"8");
> > tcsetattr(STDOUT_FILENO, TCSANOW, &old);
> > if (ENABLE_FEATURE_RESIZE_PRINT)
> > printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
> > w.ws_col, w.ws_row);
> > return ret;
>
> So it sounds like we wont be able to use the resize code that comes with
> busybox, even if we enable it (since it lacks the "regular" resize
> code's magic guesswork). It does seem cheesy to change the calls to
Let us see "regular" resize source (or download URL), maybe
bbox resize can be improved.
> more to also call resize too, but other than pulling in the source code,
> that may be what we do (or just live with 80x24 mode).
I don't like it. resize does evil hacks in order to get terminal
size (sends ESC sequences to terminal and reads response).
These hacks shouldn't propagate into more/less/top etc...
--
vda
More information about the busybox
mailing list