when to use ioctl with TIOCGWINSZ

Marty Leisner.Henr at xerox.com
Sun Jan 14 04:50:16 AEST 1990


I recently tried to bring up Elvis (a vi clone posted to comp.os.minix) on
my sun386i.

This code sequence seems to cause problems on some remote terminals (via
TCP/IP or XNS).  It works on rlogin between suns.  It doesn't work with
telnet.  It doesn't work on rlogin between a non-sun and a sun.

        /* get the window size, one way or another. */
#ifdef TIOCGWINSZ
        LINES = COLS = 0;
        if (ioctl(2, TIOCGWINSZ, &size) >= 0)
        {
                LINES = size.ws_row;
                COLS = size.ws_col;
        }
#else
        LINES = tgetnum("li");
        COLS = tgetnum("co");
#endif

Essentially, when there's a problem(?), ioctl isn't returning an error, and
LINES and COLS get set to 0.

TIOCGWINSZ returns the terminal driver's notion of the size.  I guess the
driver got the wrong notion (actually how can the driver know what size a
remote terminal is?).

How does one know when they'll get meaningful information out of
TIOCGWINSZ?

What's the correct way to handle this problem?

marty
ARPA:	leisner.henr at xerox.com
GV:  leisner.henr
NS:  leisner:wbst139:xerox
UUCP:	hplabs!arisia!leisner
 



More information about the Comp.unix.wizards mailing list