From bf1d15957e17071517ffc2aac8b460da91ba1c56 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 17 Jun 2024 13:29:59 +0000 Subject: [PATCH] Implement SIGWINCH. --- kernel/pty.cpp | 1 + kernel/tty.cpp | 11 +++++++++++ kernel/tty.h | 1 + 3 files changed, 13 insertions(+) diff --git a/kernel/pty.cpp b/kernel/pty.cpp index 4b137512..4a90b828 100644 --- a/kernel/pty.cpp +++ b/kernel/pty.cpp @@ -656,6 +656,7 @@ int PTY::master_ioctl(ioctx_t* ctx, int cmd, uintptr_t arg) const struct winsize* user_ws = (const struct winsize*) arg; if ( !ctx->copy_from_src(&ws, user_ws, sizeof(ws)) ) return -1; + winch(); return 0; } return ioctl(ctx, cmd, arg); diff --git a/kernel/tty.cpp b/kernel/tty.cpp index c31f34c8..1dc9214a 100644 --- a/kernel/tty.cpp +++ b/kernel/tty.cpp @@ -324,6 +324,17 @@ void TTY::hup() poll_channel.Signal(POLLHUP); } +void TTY::winch() // termlock taken +{ + ScopedLock family_lock(&process_family_lock); + if ( 0 < foreground_pgid ) + { + Process* process = CurrentProcess()->GetPTable()->Get(foreground_pgid); + if ( process ) + process->DeliverGroupSignal(SIGWINCH); + } +} + void TTY::ProcessUnicode(uint32_t unicode) { mbstate_t ps; diff --git a/kernel/tty.h b/kernel/tty.h index 930a8566..96f45e5f 100644 --- a/kernel/tty.h +++ b/kernel/tty.h @@ -78,6 +78,7 @@ public: public: void hup(); + void winch(); protected: void tty_output(const char* str)