Avoid leaking log file descriptors into the inferior process.

Summary:
This commit adds a new open flag File::eOpenOptionCloseOnExec (i.e., O_CLOEXEC), and adds it to
the list of flags when opening log files (#ifndef windows). A regression test is included.

Reviewers: vharron, clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7412

llvm-svn: 228310
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index 8568d8f..946f3dd 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -288,6 +288,8 @@
 #ifndef _WIN32
     if (options & eOpenOptionNonBlocking)
         oflag |= O_NONBLOCK;
+    if (options & eOpenOptionCloseOnExec)
+        oflag |= O_CLOEXEC;
 #else
     oflag |= O_BINARY;
 #endif