Skip to content
Permalink
Browse files

[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
  • Loading branch information
mgorny authored and plabath committed Oct 23, 2019
1 parent ec66603 commit 267cc3292ec4f6a7ea062b3551d20ea4692b6b78
Showing with 7 additions and 5 deletions.
  1. +7 −5 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) {

0 comments on commit 267cc32

Please sign in to comment.
You can’t perform that action at this time.