Path: utzoo!attcan!uunet!aplcen!haven!adm!news From: Leisner.Henr@xerox.com (Marty) Newsgroups: comp.unix.wizards Subject: when to use ioctl with TIOCGWINSZ Message-ID: <22086@adm.BRL.MIL> Date: 13 Jan 90 17:50:16 GMT Sender: news@adm.BRL.MIL Lines: 38 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@xerox.com GV: leisner.henr NS: leisner:wbst139:xerox UUCP: hplabs!arisia!leisner