mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Kernel: Writing to a slave PTY should yield EIO if the master is closed.
This commit is contained in:
parent
2a0700af9a
commit
0669ef8977
Notes:
sideshowbarker
2024-07-19 15:51:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0669ef8977e
7 changed files with 14 additions and 8 deletions
|
@ -61,13 +61,18 @@ void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
|
|||
m_slave = nullptr;
|
||||
}
|
||||
|
||||
void MasterPTY::on_slave_write(const byte* data, size_t size)
|
||||
ssize_t MasterPTY::on_slave_write(const byte* data, size_t size)
|
||||
{
|
||||
if (m_closed)
|
||||
return -EIO;
|
||||
m_buffer.write(data, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
bool MasterPTY::can_write_from_slave() const
|
||||
{
|
||||
if (m_closed)
|
||||
return true;
|
||||
return m_buffer.bytes_in_write_buffer() < 4096;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
|
||||
unsigned index() const { return m_index; }
|
||||
String pts_name() const;
|
||||
void on_slave_write(const byte*, size_t);
|
||||
ssize_t on_slave_write(const byte*, size_t);
|
||||
bool can_write_from_slave() const;
|
||||
void notify_slave_closed(Badge<SlavePTY>);
|
||||
bool is_closed() const { return m_closed; }
|
||||
|
|
|
@ -33,9 +33,9 @@ void SlavePTY::on_master_write(const byte* buffer, size_t size)
|
|||
emit(buffer[i]);
|
||||
}
|
||||
|
||||
void SlavePTY::on_tty_write(const byte* data, size_t size)
|
||||
ssize_t SlavePTY::on_tty_write(const byte* data, size_t size)
|
||||
{
|
||||
m_master->on_slave_write(data, size);
|
||||
return m_master->on_slave_write(data, size);
|
||||
}
|
||||
|
||||
bool SlavePTY::can_write(Process&) const
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
private:
|
||||
// ^TTY
|
||||
virtual String tty_name() const override;
|
||||
virtual void on_tty_write(const byte*, size_t) override;
|
||||
virtual ssize_t on_tty_write(const byte*, size_t) override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual bool can_read(Process&) const override;
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
void hang_up();
|
||||
|
||||
protected:
|
||||
virtual void on_tty_write(const byte*, size_t) = 0;
|
||||
virtual ssize_t on_tty_write(const byte*, size_t) = 0;
|
||||
void set_size(unsigned short columns, unsigned short rows);
|
||||
|
||||
TTY(unsigned major, unsigned minor);
|
||||
|
|
|
@ -499,11 +499,12 @@ void VirtualConsole::on_sysconsole_receive(byte ch)
|
|||
m_current_attribute = old_attribute;
|
||||
}
|
||||
|
||||
void VirtualConsole::on_tty_write(const byte* data, size_t size)
|
||||
ssize_t VirtualConsole::on_tty_write(const byte* data, size_t size)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
on_char(data[i]);
|
||||
return size;
|
||||
}
|
||||
|
||||
String VirtualConsole::tty_name() const
|
||||
|
|
|
@ -23,7 +23,7 @@ private:
|
|||
virtual void on_sysconsole_receive(byte) override;
|
||||
|
||||
// ^TTY
|
||||
virtual void on_tty_write(const byte*, size_t) override;
|
||||
virtual ssize_t on_tty_write(const byte*, size_t) override;
|
||||
virtual String tty_name() const override;
|
||||
|
||||
// ^CharacterDevice
|
||||
|
|
Loading…
Reference in a new issue