diff options
Diffstat (limited to 'Kernel/PTYMultiplexer.cpp')
-rw-r--r-- | Kernel/PTYMultiplexer.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Kernel/PTYMultiplexer.cpp b/Kernel/PTYMultiplexer.cpp new file mode 100644 index 0000000000..26403e898c --- /dev/null +++ b/Kernel/PTYMultiplexer.cpp @@ -0,0 +1,27 @@ +#include "PTYMultiplexer.h" +#include "MasterPTY.h" +#include <LibC/errno_numbers.h> + +PTYMultiplexer::PTYMultiplexer() + : CharacterDevice(5, 2) +{ + m_freelist.ensureCapacity(4); + for (int i = 4; i > 0; --i) + m_freelist.unchecked_append(adopt(*new MasterPTY(i - 1))); +} + +PTYMultiplexer::~PTYMultiplexer() +{ +} + +RetainPtr<FileDescriptor> PTYMultiplexer::open(int& error, int options) +{ + LOCKER(m_lock); + if (m_freelist.is_empty()) { + error = -EBUSY; + return nullptr; + } + auto master = m_freelist.takeLast(); + dbgprintf("PTYMultiplexer::open: Vending master %u\n", master->index()); + return VFS::the().open(move(master), error, options); +} |