serenity/Kernel/DevPtsFS.h
Andreas Kling b4e478aa50 Deallocate PTY's when they close.
This required a fair bit of plumbing. The CharacterDevice::close() virtual
will now be closed by ~FileDescriptor(), allowing device implementations to
do custom cleanup at that point.

One big problem remains: if the master PTY is closed before the slave PTY,
we go into crashy land.
2019-01-30 18:47:18 +01:00

30 lines
588 B
C++

#pragma once
#include <AK/Types.h>
#include <Kernel/SyntheticFileSystem.h>
class Process;
class SlavePTY;
class DevPtsFS final : public SynthFS {
public:
static DevPtsFS& the() PURE;
virtual ~DevPtsFS() override;
static RetainPtr<DevPtsFS> create();
virtual bool initialize() override;
virtual const char* class_name() const override;
void register_slave_pty(SlavePTY&);
void unregister_slave_pty(SlavePTY&);
private:
DevPtsFS();
RetainPtr<SynthFSInode> create_slave_pty_device_file(unsigned index);
HashTable<SlavePTY*> m_slave_ptys;
};