Kernel: TTY now stores foreground process pid

this will be process pgid when we have process groups
This commit is contained in:
Bananymous 2023-07-24 22:28:58 +03:00
parent 522aa8e762
commit b576d373c4
2 changed files with 8 additions and 0 deletions

View File

@ -23,6 +23,9 @@ namespace Kernel
uint32_t height() const { return m_height; } uint32_t height() const { return m_height; }
uint32_t width() const { return m_width; } 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 // for kprint
static void putchar_current(uint8_t ch); static void putchar_current(uint8_t ch);
static bool is_initialized(); static bool is_initialized();
@ -94,6 +97,8 @@ namespace Kernel
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE }; TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
TerminalDriver::Color m_background { TerminalColor::BLACK }; TerminalDriver::Color m_background { TerminalColor::BLACK };
pid_t m_foreground_process { 0 };
termios m_termios; termios m_termios;
struct Buffer struct Buffer

View File

@ -150,6 +150,9 @@ namespace Kernel
m_fixed_width_allocators.clear(); m_fixed_width_allocators.clear();
m_general_allocator.clear(); m_general_allocator.clear();
if (m_tty && m_tty->foreground_process() == pid())
m_tty->set_foreground_process(0);
s_process_lock.lock(); s_process_lock.lock();
for (size_t i = 0; i < s_processes.size(); i++) for (size_t i = 0; i < s_processes.size(); i++)
if (s_processes[i] == this) if (s_processes[i] == this)