resize timeout handling / grabbing size from stderr doubt

Bernhard Fischer rep.dot.nop at gmail.com
Wed Mar 14 01:13:56 PDT 2007


On Tue, Mar 13, 2007 at 10:06:52PM +0100, Denis Vlasenko wrote:
>On Tuesday 13 March 2007 09:35, Bernhard Fischer wrote:
>> On Mon, Mar 12, 2007 at 04:41:07PM -0700, vda at busybox.net wrote:
>> >Author: vda
>> >Date: 2007-03-12 16:41:07 -0700 (Mon, 12 Mar 2007)
>> >New Revision: 18080
>> >
>> >Log:
>> >resize: make it usable in in backticks; have a timeout (if display
>> >doesn't respond to 'get cursor pos' ESC sequence...)
>
>> My initial proposal had a timeout-handling already:
>> http://busybox.net/~aldot/bb/busybox.applet_resize.00c.diff
>> 
>> The timeouthandling was dropped since Rob vetoed it..
>> To me it looks like the initial timeout proposal would be smaller and
>> should work equally well, no?
>
>Your code:
>
>+#define RESIZE_TIOS_TIMEOUT 100 /* in deciseconds */
>+int resize_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv) {
>+       /* save_cursor_pos 7
>+        * scroll_whole_screen [r
>+        * put_cursor_waaaay_off [$x;$yH
>+        * get_cursor_pos [6n
>+        * restore_cursor_pos 8
>+        */
>+       struct winsize w = {0,0,0,0};
>+       int ret;
>+       struct termios old, new;
>+       tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
>+       new = old;
>+       new.c_cflag |= (CLOCAL | CREAD);
>+       new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
>+#if defined(RESIZE_TIOS_TIMEOUT) && (RESIZE_TIOS_TIMEOUT > 0)
>+       new.c_cc[VMIN] = 0;
>+       new.c_cc[VTIME] = RESIZE_TIOS_TIMEOUT;
>+#endif
>
>I must admit that I didn't know that new.c_cc[VTIME] exists,
>let alone what does it mean.

It's the timeout for a write.
I don't know how i would be able to reproduce such a write-error ?

Re: your change to use stderr to grab the winsize.
Is the winsize guaranteed to be equal for stdout and stderr for a given
process?

What about this scenario:
stdout/stdin comes from /dev/fb0 which is 80x24 and stderr is redirected
to /dev/fb1 which is (random numbers) 123x96 ?

Will svn with your recent change to use stderr correctly output 80x24 or
the incorrect 123x96 ?
>
>Googled for it. Still not much info.
>Care to enlighten me and other people on the list?
>
>It is certainly smaller that what I committed.
>If you are sure that it works reliably, you can commit this change
>(please add small educational comment then)

I don't know how i could test such a write-error. How would i be able to
reproduce this?

TIA,
Bernhard


More information about the busybox mailing list