mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
Kernel: Closing a MasterPTY should generate a TTY hangup.
This commit is contained in:
parent
378e20c535
commit
2a0700af9a
4 changed files with 13 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "PTYMultiplexer.h"
|
#include "PTYMultiplexer.h"
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
#include <LibC/signal_numbers.h>
|
||||||
|
|
||||||
MasterPTY::MasterPTY(unsigned index)
|
MasterPTY::MasterPTY(unsigned index)
|
||||||
: CharacterDevice(10, index)
|
: CharacterDevice(10, index)
|
||||||
|
@ -73,8 +74,11 @@ bool MasterPTY::can_write_from_slave() const
|
||||||
void MasterPTY::close()
|
void MasterPTY::close()
|
||||||
{
|
{
|
||||||
if (retain_count() == 2) {
|
if (retain_count() == 2) {
|
||||||
|
InterruptDisabler disabler;
|
||||||
// After the closing FileDescriptor dies, slave is the only thing keeping me alive.
|
// After the closing FileDescriptor dies, slave is the only thing keeping me alive.
|
||||||
// From this point, let's consider ourselves closed.
|
// From this point, let's consider ourselves closed.
|
||||||
m_closed = true;
|
m_closed = true;
|
||||||
|
|
||||||
|
m_slave->hang_up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
|
|
||||||
bool is_blocked() const
|
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; }
|
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_rows = rows;
|
||||||
m_columns = columns;
|
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; }
|
bool in_canonical_mode() const { return m_termios.c_lflag & ICANON; }
|
||||||
|
|
||||||
void set_default_termios();
|
void set_default_termios();
|
||||||
|
void hang_up();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void on_tty_write(const byte*, size_t) = 0;
|
virtual void on_tty_write(const byte*, size_t) = 0;
|
||||||
|
@ -38,12 +39,12 @@ protected:
|
||||||
TTY(unsigned major, unsigned minor);
|
TTY(unsigned major, unsigned minor);
|
||||||
void emit(byte);
|
void emit(byte);
|
||||||
|
|
||||||
|
void generate_signal(int signal);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ^CharacterDevice
|
// ^CharacterDevice
|
||||||
virtual bool is_tty() const final override { return true; }
|
virtual bool is_tty() const final override { return true; }
|
||||||
|
|
||||||
void generate_signal(int signal);
|
|
||||||
|
|
||||||
DoubleBuffer m_buffer;
|
DoubleBuffer m_buffer;
|
||||||
pid_t m_pgid { 0 };
|
pid_t m_pgid { 0 };
|
||||||
termios m_termios;
|
termios m_termios;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue