mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
PTY: Disallow infinite writing to slaves.
This way we don't buffer ungodly amounts of output in the kernel when doing e.g "cat /dev/random" on a PTY.
This commit is contained in:
parent
d7d78670c9
commit
b896d4b237
Notes:
sideshowbarker
2024-07-19 15:57:37 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b896d4b2377
@ -45,3 +45,8 @@ void MasterPTY::on_slave_write(const byte* data, size_t size)
|
||||
{
|
||||
m_buffer.write(data, size);
|
||||
}
|
||||
|
||||
bool MasterPTY::can_write_from_slave() const
|
||||
{
|
||||
return m_buffer.bytes_in_write_buffer() < 4096;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
unsigned index() const { return m_index; }
|
||||
String pts_name() const;
|
||||
void on_slave_write(const byte*, size_t);
|
||||
bool can_write_from_slave() const;
|
||||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
|
@ -31,7 +31,7 @@ void SlavePTY::on_tty_write(const byte* data, size_t size)
|
||||
m_master.on_slave_write(data, size);
|
||||
}
|
||||
|
||||
bool SlavePTY::can_write(Process& process) const
|
||||
bool SlavePTY::can_write(Process&) const
|
||||
{
|
||||
return m_master.can_write(process);
|
||||
return m_master.can_write_from_slave();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user