diff --git a/kernel/include/kernel/Terminal/TTY.h b/kernel/include/kernel/Terminal/TTY.h index bf83e7c6b..43d81c6ba 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 76a28bc59..6a7b22dea 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)