================ @@ -158,13 +156,25 @@ std::string RunInTerminalDebugAdapterCommChannel::GetLauncherError() { } Expected<std::shared_ptr<FifoFile>> CreateRunInTerminalCommFile() { + int comm_fd; SmallString<256> comm_file; - if (std::error_code EC = sys::fs::getPotentiallyUniqueTempFileName( - "lldb-dap-run-in-terminal-comm", "", comm_file)) + if (std::error_code EC = createUniqueNamedPipe( + "lldb-dap-run-in-terminal-comm", "", comm_fd, comm_file)) return createStringError(EC, "Error making unique file name for " "runInTerminal communication files"); - - return CreateFifoFile(comm_file.str()); + FILE *cf = fdopen(comm_fd, "r+"); + if (setvbuf(cf, NULL, _IONBF, 0)) + return createStringError(std::error_code(errno, std::generic_category()), + "Error setting unbuffered mode on C FILE"); + // There is no portable way to conjure an ofstream from HANDLE, so use FILE * + // llvm::raw_fd_stream does not support getline() and there is no + // llvm::buffer_istream ---------------- SuibianP wrote:
On the client (launcher) side it should be possible, but on the server end I suppose not. Windows has the distinction of "server" (from `CreateNamedPipe`) and "client" (from `CreateFile`) ends of FIFOs and unlike on POSIX where FIFOs can read from any previous write, clients can only communicate with server but not fellow clients. Opening a `std::ofstream` (which underlyingly is `CreateFile`) would open a client of the pipe in the same process that connects to the server. The server side must use `CreateNamedPipe` which gives out a `HANDLE`, thus the issue of turning that into some platform independent file object. https://github.com/llvm/llvm-project/pull/121269 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits