I use the next to change terminal size:
rc = ioctl(fd, TIOCSWINSZ, &ws);
When I run this under linux text terminal (switching by Alt-Ctrl-F1), the
Usually TIOCSWINSZ
is used by the tty master (such as xterm
, the Linux console itself, etc...) to tell the kernel driver how big the terminal actually is. The program running on the tty slave (i.e. the application itself) uses TIOCGWINSZ
to query the size of the terminal. Most tty drivers don't support pushing it the other way; you can't in general call TIOCSWINSZ
on the tty slave from the application and get the master to change its size.
Some terminals, such as xterm
do support escape sequences to request them to resize, but this is just a byte escape sequence, and not an ioctl()
command.
If you want the application to force the size of the terminal, then portably there is no way to do this. Unportably, you can apply a few special tricks like attempting TIOCSWINSZ
or sending the xterm
escape sequence.