[Lldb-commits] [lldb] [lldb-dap] Ensure we do not print the close sentinel when closing stdout. (PR #126833)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 23:56:36 PST 2025


================
@@ -58,16 +56,19 @@ Error OutputRedirector::RedirectTo(std::function<void(StringRef)> callback) {
     char buffer[OutputBufferSize];
     while (!m_stopped) {
       ssize_t bytes_count = ::read(read_fd, &buffer, sizeof(buffer));
-      // EOF detected.
-      if (bytes_count == 0)
-        break;
       if (bytes_count == -1) {
         // Skip non-fatal errors.
         if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)
           continue;
         break;
       }
 
+      StringRef data(buffer, bytes_count);
+      if (m_stopped)
+        data.consume_back(kCloseSentinel);
+      if (data.empty())
+        break;
+
       callback(StringRef(buffer, bytes_count));
----------------
labath wrote:

```suggestion
      callback(data);
```

https://github.com/llvm/llvm-project/pull/126833


More information about the lldb-commits mailing list