summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/PseudoTerminal.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-02-09 11:37:56 +0000
committerPavel Labath <labath@google.com>2015-02-09 11:37:56 +0000
commitb4bf1c65b72fe68f59fb411b26f5875d1ca22b54 (patch)
tree2776e7d654fbc296913b4437ee85a85f3b42b0e6 /lldb/source/Utility/PseudoTerminal.cpp
parentdd4f052db6ca4ee02f4fc564488a9a6ca5434003 (diff)
downloadbcm5719-llvm-b4bf1c65b72fe68f59fb411b26f5875d1ca22b54.tar.gz
bcm5719-llvm-b4bf1c65b72fe68f59fb411b26f5875d1ca22b54.zip
Fix descriptor leak in multi-target debugging
Summary: When debugging two targets concurrently, the pseude terminal master fd from the first one would leak into the second. This fixes the problem by setting O_CLOEXEC on the master fd. Test included. Reviewers: clayborg, vharron Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7466 llvm-svn: 228570
Diffstat (limited to 'lldb/source/Utility/PseudoTerminal.cpp')
-rw-r--r--lldb/source/Utility/PseudoTerminal.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lldb/source/Utility/PseudoTerminal.cpp b/lldb/source/Utility/PseudoTerminal.cpp
index e90955d37d4..55d4a9a1fc1 100644
--- a/lldb/source/Utility/PseudoTerminal.cpp
+++ b/lldb/source/Utility/PseudoTerminal.cpp
@@ -239,7 +239,7 @@ PseudoTerminal::Fork (char *error_str, size_t error_len)
error_str[0] = '\0';
pid_t pid = LLDB_INVALID_PROCESS_ID;
- if (OpenFirstAvailableMaster (O_RDWR, error_str, error_len))
+ if (OpenFirstAvailableMaster (O_RDWR | O_CLOEXEC, error_str, error_len))
{
// Successfully opened our master pseudo terminal
@@ -258,7 +258,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)
OpenPOWER on IntegriCloud