diff --git a/Kernel/MasterPTY.cpp b/Kernel/MasterPTY.cpp index 40511ac501..44cd81de65 100644 --- a/Kernel/MasterPTY.cpp +++ b/Kernel/MasterPTY.cpp @@ -3,6 +3,7 @@ #include "PTYMultiplexer.h" #include #include +#include MasterPTY::MasterPTY(unsigned index) : CharacterDevice(10, index) @@ -73,8 +74,11 @@ bool MasterPTY::can_write_from_slave() const void MasterPTY::close() { if (retain_count() == 2) { + InterruptDisabler disabler; // After the closing FileDescriptor dies, slave is the only thing keeping me alive. // From this point, let's consider ourselves closed. m_closed = true; + + m_slave->hang_up(); } } diff --git a/Kernel/Process.h b/Kernel/Process.h index a7e20040a9..6b6fe4f1b0 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -87,7 +87,7 @@ public: bool is_blocked() const { - return m_state == BlockedSleep || m_state == BlockedWait || m_state == BlockedRead || m_state == BlockedSignal || m_state == BlockedSelect; + return m_state == BlockedSleep || m_state == BlockedWait || m_state == BlockedRead || m_state == BlockedWrite || m_state == BlockedSignal || m_state == BlockedSelect; } PageDirectory& page_directory() { return *m_page_directory; } diff --git a/Kernel/TTY.cpp b/Kernel/TTY.cpp index f5be22e864..df119bcf25 100644 --- a/Kernel/TTY.cpp +++ b/Kernel/TTY.cpp @@ -161,3 +161,8 @@ void TTY::set_size(unsigned short columns, unsigned short rows) m_rows = rows; m_columns = columns; } + +void TTY::hang_up() +{ + generate_signal(SIGHUP); +} diff --git a/Kernel/TTY.h b/Kernel/TTY.h index 686f69dbd7..80f4b284e1 100644 --- a/Kernel/TTY.h +++ b/Kernel/TTY.h @@ -30,6 +30,7 @@ public: bool in_canonical_mode() const { return m_termios.c_lflag & ICANON; } void set_default_termios(); + void hang_up(); protected: virtual void on_tty_write(const byte*, size_t) = 0; @@ -38,12 +39,12 @@ protected: TTY(unsigned major, unsigned minor); void emit(byte); + void generate_signal(int signal); + private: // ^CharacterDevice virtual bool is_tty() const final override { return true; } - void generate_signal(int signal); - DoubleBuffer m_buffer; pid_t m_pgid { 0 }; termios m_termios;