1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

Add basic PTY support.

For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
This commit is contained in:
Andreas Kling 2019-01-15 06:30:19 +01:00
parent ecb4ab0943
commit 2f74c2f430
21 changed files with 287 additions and 10 deletions

26
Kernel/MasterPTY.h Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include <VirtualFileSystem/CharacterDevice.h>
#include "DoubleBuffer.h"
class SlavePTY;
class MasterPTY final : public CharacterDevice {
public:
explicit MasterPTY(unsigned index);
virtual ~MasterPTY() override;
void set_slave(SlavePTY& slave) { m_slave = &slave; }
virtual ssize_t read(byte*, size_t) override;
virtual ssize_t write(const byte*, size_t) override;
virtual bool has_data_available_for_reading(Process&) const override;
virtual bool is_master_pty() const override { return true; }
String pts_name() const;
void on_slave_write(const byte*, size_t);
private:
unsigned m_index;
SlavePTY* m_slave { nullptr };
DoubleBuffer m_buffer;
};