Can't change terminal size on pty/N (works on ttyN)

后端 未结 1 592
盖世英雄少女心
盖世英雄少女心 2021-01-13 05:48

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

相关标签:
1条回答
  • 2021-01-13 06:04

    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.

    0 讨论(0)
提交回复
热议问题