mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
9dd29f9aa9
When you open /dev/ptmx, you get a file descriptor pointing to one of the available MasterPTY's. If none are available, you get an EBUSY. This makes it possible to open multiple (up to 4) Terminals. :^) To support this, I also added a CharacterDevice::open() that gets control when VFS is opening a CharacterDevice. This is useful when we want to return a custom FileDescriptor like we do here.
28 lines
743 B
C++
28 lines
743 B
C++
#pragma once
|
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
|
#include "DoubleBuffer.h"
|
|
|
|
class SlavePTY;
|
|
|
|
class MasterPTY final : public CharacterDevice {
|
|
public:
|
|
explicit MasterPTY(unsigned index);
|
|
virtual ~MasterPTY() override;
|
|
|
|
virtual ssize_t read(Process&, byte*, size_t) override;
|
|
virtual ssize_t write(Process&, const byte*, size_t) override;
|
|
virtual bool can_read(Process&) const override;
|
|
virtual bool can_write(Process&) const override;
|
|
virtual bool is_master_pty() const override { return true; }
|
|
|
|
unsigned index() const { return m_index; }
|
|
String pts_name() const;
|
|
void on_slave_write(const byte*, size_t);
|
|
|
|
private:
|
|
SlavePTY& m_slave;
|
|
unsigned m_index;
|
|
DoubleBuffer m_buffer;
|
|
};
|