diff options
author | Michal Gorny <mgorny@gentoo.org> | 2019-10-23 06:17:25 -0700 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2019-10-24 11:29:00 -0700 |
commit | 267cc3292ec4f6a7ea062b3551d20ea4692b6b78 (patch) | |
tree | fbe33afd6b14dcde912529da57986c76b0702368 /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | ec66603ac7ea655be5c2c5f508c5bf0d5eaeb65b (diff) | |
download | bcm5719-llvm-267cc3292ec4f6a7ea062b3551d20ea4692b6b78.tar.gz bcm5719-llvm-267cc3292ec4f6a7ea062b3551d20ea4692b6b78.zip |
[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
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 70d93424fde..2b85ebf18c6 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) { |