From b576d373c40dd42303f18424456537a24a5194db Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 24 Jul 2023 22:28:58 +0300 Subject: [PATCH] Kernel: TTY now stores foreground process pid this will be process pgid when we have process groups --- kernel/include/kernel/Terminal/TTY.h | 5 +++++ kernel/kernel/Process.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/kernel/include/kernel/Terminal/TTY.h b/kernel/include/kernel/Terminal/TTY.h index bf83e7c6bb..43d81c6bad 100644 --- a/kernel/include/kernel/Terminal/TTY.h +++ b/kernel/include/kernel/Terminal/TTY.h @@ -23,6 +23,9 @@ namespace Kernel uint32_t height() const { return m_height; } uint32_t width() const { return m_width; } + void set_foreground_process(pid_t pgid) { m_foreground_process = pgid; } + pid_t foreground_process() const { return m_foreground_process; } + // for kprint static void putchar_current(uint8_t ch); static bool is_initialized(); @@ -94,6 +97,8 @@ namespace Kernel TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE }; TerminalDriver::Color m_background { TerminalColor::BLACK }; + pid_t m_foreground_process { 0 }; + termios m_termios; struct Buffer diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 76a28bc59c..6a7b22dea0 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -150,6 +150,9 @@ namespace Kernel m_fixed_width_allocators.clear(); m_general_allocator.clear(); + if (m_tty && m_tty->foreground_process() == pid()) + m_tty->set_foreground_process(0); + s_process_lock.lock(); for (size_t i = 0; i < s_processes.size(); i++) if (s_processes[i] == this)