10#include "lldb/Host/Config.h"
12#include "llvm/Support/Errc.h"
13#include "llvm/Support/Errno.h"
27#include <Availability.h>
30#if defined(__ANDROID__)
71 return llvm::errorCodeToError(
72 std::error_code(errno, std::generic_category()));
77 std::error_code EC(errno, std::generic_category());
79 return llvm::errorCodeToError(EC);
84 std::error_code EC(errno, std::generic_category());
86 return llvm::errorCodeToError(EC);
89 return llvm::Error::success();
91 return llvm::errorCodeToError(llvm::errc::not_supported);
101 return llvm::Error::success();
103 return llvm::errorCodeToError(
104 std::error_code(errno, std::generic_category()));
107#if !HAVE_PTSNAME_R || defined(__APPLE__)
109 static std::mutex mutex;
110 std::lock_guard<std::mutex> guard(mutex);
112 assert(r !=
nullptr);
120#if defined(__APPLE__)
121 if (__builtin_available(macos 10.13.4, iOS 11.3, tvOS 11.3, watchOS 4.4, *)) {
129#if defined(__APPLE__)
142 return std::move(Err);
146 return llvm::errorCodeToError(
147 std::error_code(errno, std::generic_category()));
158 return std::move(Err);
164#if defined(TIOCSCTTY)
167 return llvm::errorCodeToError(
168 std::error_code(errno, std::generic_category()));
172 for (
int fd : {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO}) {
174 return llvm::errorCodeToError(
175 std::error_code(errno, std::generic_category()));
static std::string use_ptsname(int fd)
int Open(const char *path, int flags, int mode=0600)
Wraps ::open in a platform-independent way.
static FileSystem & Instance()
PseudoTerminal()
Default constructor.
int m_secondary_fd
The file descriptor for the secondary.
int ReleaseSecondaryFileDescriptor()
Release the secondary file descriptor.
llvm::Error OpenFirstAvailablePrimary(int oflag)
Open the first available pseudo terminal.
llvm::Error OpenSecondary(int oflag)
Open the secondary for the current primary pseudo terminal.
void ClosePrimaryFileDescriptor()
Close the primary file descriptor if it is valid.
int m_primary_fd
The file descriptor for the primary.
llvm::Expected< lldb::pid_t > Fork()
Fork a child process that uses pseudo terminals for its stdio.
int GetPrimaryFileDescriptor() const
The primary file descriptor accessor.
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
std::string GetSecondaryName() const
Get the name of the secondary pseudo terminal.
void CloseSecondaryFileDescriptor()
Close the secondary file descriptor if it is valid.
int GetSecondaryFileDescriptor() const
The secondary file descriptor accessor.
@ invalid_fd
Invalid file descriptor value.
~PseudoTerminal()
Destructor.
#define UNUSED_IF_ASSERT_DISABLED(x)
A class that represents a running process on the host machine.
int posix_openpt(int flag)