aboutsummaryrefslogtreecommitdiff
path: root/source/Utility/PseudoTerminal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Utility/PseudoTerminal.cpp')
-rw-r--r--source/Utility/PseudoTerminal.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/source/Utility/PseudoTerminal.cpp b/source/Utility/PseudoTerminal.cpp
index e90955d37d4c..bc3cfee226f8 100644
--- a/source/Utility/PseudoTerminal.cpp
+++ b/source/Utility/PseudoTerminal.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/Host/Config.h"
#include "lldb/Utility/PseudoTerminal.h"
#include <errno.h>
@@ -33,6 +34,7 @@ pid_t fork(void) { return 0; }
pid_t setsid(void) { return 0; }
#elif defined(__ANDROID_NDK__)
#include "lldb/Host/android/Android.h"
+int posix_openpt(int flags);
#endif
using namespace lldb_utility;
@@ -237,9 +239,11 @@ PseudoTerminal::Fork (char *error_str, size_t error_len)
{
if (error_str)
error_str[0] = '\0';
-
pid_t pid = LLDB_INVALID_PROCESS_ID;
- if (OpenFirstAvailableMaster (O_RDWR, error_str, error_len))
+#if !defined(LLDB_DISABLE_POSIX)
+ int flags = O_RDWR;
+ flags |= O_CLOEXEC;
+ if (OpenFirstAvailableMaster (flags, error_str, error_len))
{
// Successfully opened our master pseudo terminal
@@ -258,7 +262,8 @@ PseudoTerminal::Fork (char *error_str, size_t error_len)
if (OpenSlave (O_RDWR, error_str, error_len))
{
// Successfully opened slave
- // We are done with the master in the child process so lets close it
+
+ // Master FD should have O_CLOEXEC set, but let's close it just in case...
CloseMasterFileDescriptor ();
#if defined(TIOCSCTTY)
@@ -295,6 +300,7 @@ PseudoTerminal::Fork (char *error_str, size_t error_len)
// Do nothing and let the pid get returned!
}
}
+#endif
return pid;
}