https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/212745
>From 773ecbd8b0822c8a5a7246dfa4555b6df0d6f56e Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 29 Jul 2026 12:35:23 +0100 Subject: [PATCH 1/3] [lldb][Windows] Check for EOF before the ctrl-c retry in GetLine --- lldb/source/Core/IOHandler.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 0bb8b58f24bff..a4477e4931b15 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -395,23 +395,24 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) { while (!got_line) { char *r = fgets(buffer, sizeof(buffer), in); #ifdef _WIN32 - // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED - // according to the docs on MSDN. However, this has evidently been a - // known bug since Windows 8. Therefore, we can't detect if a signal - // interrupted in the fgets. So pressing ctrl-c causes the repl to end - // and the process to exit. A temporary workaround is just to attempt to - // fgets twice until this bug is fixed. - if (r == nullptr) - r = fgets(buffer, sizeof(buffer), in); - // this is the equivalent of EINTR for Windows - if (r == nullptr && GetLastError() == ERROR_OPERATION_ABORTED) - continue; -#endif if (r == nullptr) { + if (feof(in)) { + got_line = SplitLineEOF(m_line_buffer); + break; + } if (ferror(in) && errno == EINTR) continue; - if (feof(in)) - got_line = SplitLineEOF(m_line_buffer); + // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED + // according to the docs on MSDN. However, this has evidently been a + // known bug since Windows 8. Therefore, we can't detect if a signal + // interrupted in the fgets. So pressing ctrl-c causes the repl to end + // and the process to exit. A temporary workaround is just to attempt + // to fgets twice until this bug is fixed. + if (GetLastError() == ERROR_OPERATION_ABORTED) { + clearerr(in); + continue; + } +#endif break; } m_line_buffer += buffer; >From c34c4e916b6e76ae59ec4f17d6f6d678cde7e6e8 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 29 Jul 2026 12:53:32 +0100 Subject: [PATCH 2/3] fixup! [lldb][Windows] Check for EOF before the ctrl-c retry in GetLine --- lldb/source/Core/IOHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index a4477e4931b15..7553df36dfa54 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -394,8 +394,8 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) { if (!got_line && in) { while (!got_line) { char *r = fgets(buffer, sizeof(buffer), in); -#ifdef _WIN32 if (r == nullptr) { +#ifdef _WIN32 if (feof(in)) { got_line = SplitLineEOF(m_line_buffer); break; >From c0cae73e480a6a8e5b592ac88e59e97e1592af61 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 29 Jul 2026 15:07:24 +0100 Subject: [PATCH 3/3] fixup! [lldb][Windows] Check for EOF before the ctrl-c retry in GetLine --- lldb/source/Core/IOHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 7553df36dfa54..f0dad316cb0fe 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -395,13 +395,13 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) { while (!got_line) { char *r = fgets(buffer, sizeof(buffer), in); if (r == nullptr) { -#ifdef _WIN32 if (feof(in)) { got_line = SplitLineEOF(m_line_buffer); break; } if (ferror(in) && errno == EINTR) continue; +#ifdef _WIN32 // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED // according to the docs on MSDN. However, this has evidently been a // known bug since Windows 8. Therefore, we can't detect if a signal _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
