================
@@ -128,19 +131,28 @@ llvm::Error PseudoConsole::OpenPseudoConsole() {
   return llvm::Error::success();
 }
 
+bool PseudoConsole::IsConnected() const {
+  return m_conpty_handle != INVALID_HANDLE_VALUE &&
+         m_conpty_input != INVALID_HANDLE_VALUE &&
+         m_conpty_output != INVALID_HANDLE_VALUE;
+}
+
 void PseudoConsole::Close() {
-  Sleep(50); // FIXME: This mitigates a race condition when closing the
-             // PseudoConsole. It's possible that there is still data in the
-             // pipe when we try to close it. We should wait until the data has
-             // been consumed.
+  SetStopping(true);
----------------
Nerixyz wrote:

When debugging, I noticed we call this more than once. This isn't a big issue, 
because all calls after the first one are essentially no-ops. 

If `m_conpty_handle == INVALID_HANDLE_VALUE`, we could return early, right? 
That check shouldn't need to be synchronized with other threads, because only 
one thread is closing the pseudo console.

https://github.com/llvm/llvm-project/pull/182302
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to