aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-02-06 11:32:52 +0000
committerPavel Labath <labath@google.com>2015-02-06 11:32:52 +0000
commit3a2da9eb0deb330d7cd85bfc40f3761875e68b4e (patch)
treebf159f741e8aae5f8a396e54f8e38f5f9f52b379 /lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
parent77f62d45ef61fb923636ceb3ecee42e490a56e1c (diff)
downloadllvm-3a2da9eb0deb330d7cd85bfc40f3761875e68b4e.zip
llvm-3a2da9eb0deb330d7cd85bfc40f3761875e68b4e.tar.gz
llvm-3a2da9eb0deb330d7cd85bfc40f3761875e68b4e.tar.bz2
Fix TestProcesslaunch regression caused by D7372
Summary: After closing all the leaked file descriptors to the inferior tty, the following problem occured: - when stdin, stdout and stderr are redirected, there are no slave descriptors open (which is good) - lldb has a reader thread, which attempts to read from the master end of the tty - this thread receives an EOF - in response, it closes it's master end - as this is the last open file descriptor for the master end, this deletes the tty and sends SIGHUP to the inferior (this is bad) I fix this problem by making sure the master end remains open for the duration of the inferior process by storing a copy of the file descriptor in ProcessMonitor. I create a copy to avoid ownership issues with the reading thread. Reviewers: ovyalov, emaste Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7440 llvm-svn: 228391
Diffstat (limited to 'lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp')
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
index 0e5ab5a..882fac7 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -252,7 +252,16 @@ ProcessPOSIX::DoLaunch (Module *module,
if (!error.Success())
return error;
- SetSTDIOFileDescriptor(m_monitor->GetTerminalFD());
+ int terminal = m_monitor->GetTerminalFD();
+ if (terminal >= 0) {
+ // The reader thread will close the file descriptor when done, so we pass it a copy.
+ int stdio = fcntl(terminal, F_DUPFD_CLOEXEC, 0);
+ if (stdio == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+ SetSTDIOFileDescriptor(stdio);
+ }
SetID(m_monitor->GetPID());
return error;