1 //===-- PseudoTerminal.h ----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Created by Greg Clayton on 1/8/08.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_PSEUDOTERMINAL_H
14 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_PSEUDOTERMINAL_H
20 class PseudoTerminal
{
22 enum { invalid_fd
= -1, invalid_pid
= -1 };
26 err_posix_openpt_failed
= -2,
27 err_grantpt_failed
= -3,
28 err_unlockpt_failed
= -4,
29 err_ptsname_failed
= -5,
30 err_open_secondary_failed
= -6,
32 err_setsid_failed
= -8,
33 err_failed_to_acquire_controlling_terminal
= -9,
34 err_dup2_failed_on_stdin
= -10,
35 err_dup2_failed_on_stdout
= -11,
36 err_dup2_failed_on_stderr
= -12
38 // Constructors and Destructors
43 void CloseSecondary();
44 Status
OpenFirstAvailablePrimary(int oflag
);
45 Status
OpenSecondary(int oflag
);
46 int PrimaryFD() const { return m_primary_fd
; }
47 int SecondaryFD() const { return m_secondary_fd
; }
48 int ReleasePrimaryFD() {
49 // Release ownership of the primary pseudo terminal file
50 // descriptor without closing it. (the destructor for this
51 // class will close it otherwise!)
52 int fd
= m_primary_fd
;
53 m_primary_fd
= invalid_fd
;
56 int ReleaseSecondaryFD() {
57 // Release ownership of the secondary pseudo terminal file
58 // descriptor without closing it (the destructor for this
59 // class will close it otherwise!)
60 int fd
= m_secondary_fd
;
61 m_secondary_fd
= invalid_fd
;
65 const char *SecondaryName() const;
67 pid_t
Fork(Status
&error
);
70 // Classes that inherit from PseudoTerminal can see and modify these
75 PseudoTerminal(const PseudoTerminal
&rhs
) = delete;
76 PseudoTerminal
&operator=(const PseudoTerminal
&rhs
) = delete;
79 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_PSEUDOTERMINAL_H