mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00

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.
27 lines
528 B
C++
27 lines
528 B
C++
#pragma once
|
|
|
|
#include "TTY.h"
|
|
|
|
class MasterPTY;
|
|
|
|
class SlavePTY final : public TTY {
|
|
public:
|
|
virtual ~SlavePTY() override;
|
|
|
|
virtual String tty_name() const override;
|
|
|
|
void on_master_write(const byte*, size_t);
|
|
unsigned index() const { return m_index; }
|
|
|
|
protected:
|
|
virtual void on_tty_write(const byte*, size_t) override;
|
|
virtual bool can_write(Process&) const override;
|
|
|
|
private:
|
|
friend class MasterPTY;
|
|
SlavePTY(MasterPTY&, unsigned index);
|
|
|
|
MasterPTY& m_master;
|
|
unsigned m_index;
|
|
};
|
|
|