mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Kernel: Closing a MasterPTY should generate a TTY hangup.
This commit is contained in:
parent
378e20c535
commit
2a0700af9a
Notes:
sideshowbarker
2024-07-19 15:51:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2a0700af9ac
4 changed files with 13 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "PTYMultiplexer.h"
|
||||
#include <Kernel/Process.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
#include <LibC/signal_numbers.h>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue