ladybird/Kernel/TTY.h
Andreas Kling 10b666f69a Basic ^C interrupt implementation.
For testing, I made cat put itself into a new process group.
This should eventually be done by sh between fork() and exec().
2018-11-02 14:06:48 +01:00

32 lines
693 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 { return true; }
TTY(unsigned major, unsigned minor);
void emit(byte);
virtual void onTTYWrite(byte) = 0;
void interrupt();
private:
Vector<byte> m_buffer;
pid_t m_pgid { 0 };
};