ioctl() fails to get window size from console login

Hi,

I need to get the console window size for an application, for which I used ioctl() by passing the TIOCGWINSZ parameter. The ioctl() function does not fail (returns non zero), but it could not get the window size (gets 0x0). When I tried to verify the window size by the stty -a command, the entry for the cols and lines shows 0. I guess the tty sub-system is not giving the correct window size. The behaviour is only in Solaris and from console login only. From xterm it works fine. In AIX also the program works fine. If anybody can help, kindly get back to me.

Regards,
Diganta

The console uses a real tty driver, not a pseudo tty driver. You could plug an old asr 33 teletype into the serial port and use it as a (printing) terminal. What is the window size then? You can use TIOCSWINSZ to set the window size to whatever you like. Then TIOCGWINSZ will return that value. Combine the two, and you can set a default if the values are zero. This can be done in your shell's start up scripts with the tput and stty programs.
lines=`tput lines` will get the current value and
stty rows $lines will set the value. For columns, use "cols" in both commands.

Thanks! My problem is solved.