John Harrison c2e96778e0
[lldb-dap] Ensure we do not print the close sentinel when closing stdout. (#126833)
If you have an lldb-dap log file you'll almost always see a final
message like:

```
<-- 
Content-Length: 94

{
  "body": {
    "category": "stdout",
    "output": "\u0000\u0000"
  },
  "event": "output",
  "seq": 0,
  "type": "event"
}
<-- 
Content-Length: 94

{
  "body": {
    "category": "stderr",
    "output": "\u0000\u0000"
  },
  "event": "output",
  "seq": 0,
  "type": "event"
}
```

The OutputRedirect is always writing the `"\0"` byte as a final stdout
message during shutdown. Instead, I adjusted this to detect the sentinel
value and break out of the read loop as if we detected EOF.

---------

Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-02-13 10:35:50 -08:00

16 lines
387 B
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
// Ensure multiple partial lines are detected and sent.
printf("abc");
printf("def");
printf("ghi\n");
printf("hello world\n"); // breakpoint 1
// Ensure the OutputRedirector does not consume the programs \0\0 output.
char buf[] = "finally\0";
write(STDOUT_FILENO, buf, sizeof(buf));
return 0;
}