// Global variables to store current terminal size
int fdm, fds;
void sigwinch_handler(int signo)
{
struct winsize ws;
// Get the current window size
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
// Update global variables with new window size
ioctl(fdm, TIOCSWINSZ, &ws);
}
//main.c
// 根据信号读取窗口大小设置 stty宽高 stty size
signal(SIGWINCH, sigwinch_handler);
04-15