[Lldb-commits] [PATCH] D69320: [lldb] [Python] Do not attempt to flush() a read-only fd
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 22 12:58:25 PDT 2019
mgorny created this revision.
mgorny added reviewers: lawrence_danna, labath, krytarowski.
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.
https://reviews.llvm.org/D69320
Files:
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1367,11 +1367,13 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69320.226075.patch
Type: text/x-patch
Size: 818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191022/b5e21c5e/attachment.bin>
More information about the lldb-commits
mailing list