[Lldb-commits] [lldb] 267cc32 - [lldb] [Python] Do not attempt to flush() a read-only fd

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 24 11:29:30 PDT 2019


Author: Michal Gorny
Date: 2019-10-24T11:29:00-07:00
New Revision: 267cc3292ec4f6a7ea062b3551d20ea4692b6b78

URL: https://github.com/llvm/llvm-project/commit/267cc3292ec4f6a7ea062b3551d20ea4692b6b78
DIFF: https://github.com/llvm/llvm-project/commit/267cc3292ec4f6a7ea062b3551d20ea4692b6b78.diff

LOG: [lldb] [Python] Do not attempt to flush() a read-only fd

Summary:
When creating a FileSP object, do not flush() the underlying file unless
it is open for writing.  Attempting to flush() a read-only fd results
in EBADF on NetBSD.

Reviewers: lawrence_danna, labath, krytarowski

Reviewed By: lawrence_danna, labath

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69320

Added: 
    

Modified: 
    lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 70d93424fdec..2b85ebf18c6a 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1385,11 +1385,13 @@ llvm::Expected<FileSP> PythonFile::ConvertToFile(bool borrowed) {
   if (!options)
     return options.takeError();
 
-  // LLDB and python will not share I/O buffers.  We should probably
-  // flush the python buffers now.
-  auto r = CallMethod("flush");
-  if (!r)
-    return r.takeError();
+  if (options.get() & File::eOpenOptionWrite) {
+    // LLDB and python will not share I/O buffers.  We should probably
+    // flush the python buffers now.
+    auto r = CallMethod("flush");
+    if (!r)
+      return r.takeError();
+  }
 
   FileSP file_sp;
   if (borrowed) {


        


More information about the lldb-commits mailing list