Kernel/LibC: Rework TIOC{G,S}WINSZ more linux like

Userspace can freely set terminal size, kernel just updates it when for
example new font is loaded. Also SIGWINCH is now sent by kernel instead
of userspace.
This commit is contained in:
2025-06-28 16:26:13 +03:00
parent 521457eb92
commit e8491b34b8
12 changed files with 62 additions and 77 deletions

View File

@@ -128,9 +128,12 @@ void Terminal::run()
m_window->set_min_size(m_font.width() * 8, m_font.height() * 2);
{
winsize winsize;
winsize.ws_col = cols();
winsize.ws_row = rows();
winsize winsize {
.ws_row = static_cast<unsigned short>(rows()),
.ws_col = static_cast<unsigned short>(cols()),
.ws_xpixel = static_cast<unsigned short>(m_window->width()),
.ws_ypixel = static_cast<unsigned short>(m_window->height()),
};
if (ioctl(m_shell_info.pts_master, TIOCSWINSZ, &winsize) == -1)
perror("ioctl");
}
@@ -170,6 +173,8 @@ void Terminal::run()
const winsize winsize {
.ws_row = static_cast<unsigned short>(rows()),
.ws_col = static_cast<unsigned short>(cols()),
.ws_xpixel = static_cast<unsigned short>(m_window->width()),
.ws_ypixel = static_cast<unsigned short>(m_window->height()),
};
if (ioctl(m_shell_info.pts_master, TIOCSWINSZ, &winsize) == -1)
{
@@ -183,12 +188,6 @@ void Terminal::run()
perror("tcgetpgrp");
return;
}
if (kill(-fgpgrp, SIGWINCH) == -1)
{
perror("kill");
return;
}
});
const int max_fd = BAN::Math::max(m_shell_info.pts_master, m_window->server_fd());