serenity/Kernel/TTY.h
Andreas Kling da3857b0c2 Add some simple write buffering to LibC's stdio.
Plumb it all the way to the VirtualConsole. Also fix /bin/cat to write()
the whole chunks we get from read() directly to stdout.
2018-11-08 01:23:47 +01:00

32 lines
717 B
C++

#pragma once
#include <VirtualFileSystem/CharacterDevice.h>
class TTY : public CharacterDevice {
public:
virtual ~TTY() override;
virtual ssize_t read(byte*, size_t) override;
virtual ssize_t write(const byte*, size_t) override;
virtual bool hasDataAvailableForRead() const override;
virtual String ttyName() const = 0;
void set_pgid(pid_t pgid) { m_pgid = pgid; }
pid_t pgid() const { return m_pgid; }
protected:
virtual bool isTTY() const final override { return true; }
TTY(unsigned major, unsigned minor);
void emit(byte);
virtual void onTTYWrite(const byte*, size_t) = 0;
void interrupt();
private:
Vector<byte> m_buffer;
pid_t m_pgid { 0 };
};