[Lldb-commits] [lldb] r258367 - Fix a problem where we were not calling fcntl() with the correct arguments for F_DUPFD

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 20 15:20:11 PST 2016


Author: enrico
Date: Wed Jan 20 17:20:10 2016
New Revision: 258367

URL: http://llvm.org/viewvc/llvm-project?rev=258367&view=rev
Log:
Fix a problem where we were not calling fcntl() with the correct arguments for F_DUPFD

On Mac OS X, this was working just fine in debug builds (presumably, because the right value ended up being at the right location for the variadic ABI), but not in Release builds
As a result, we were seeing failures with commands that set their own immediate output stream - only in Release builds, which always makes for a fun little investigation

I have removed those fcntl() calls and replaced them with dup() calls. This fixes the issue in both Debug and Release builds


Modified:
    lldb/trunk/source/Host/common/File.cpp

Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=258367&r1=258366&r2=258367&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Wed Jan 20 17:20:10 2016
@@ -191,7 +191,7 @@ File::GetStream ()
 #ifdef _WIN32
                     m_descriptor = ::_dup(GetDescriptor());
 #else
-                    m_descriptor = ::fcntl(GetDescriptor(), F_DUPFD);
+                    m_descriptor = dup(GetDescriptor());
 #endif
                     m_should_close_fd = true;
                 }
@@ -237,7 +237,7 @@ File::Duplicate (const File &rhs)
 #ifdef _WIN32
         m_descriptor = ::_dup(rhs.GetDescriptor());
 #else
-        m_descriptor = ::fcntl(rhs.GetDescriptor(), F_DUPFD);
+        m_descriptor = dup(rhs.GetDescriptor());
 #endif
         if (!DescriptorIsValid())
             error.SetErrorToErrno();




More information about the lldb-commits mailing list