From ebcf8126dc0c212d18638f8650ea757fa150ba17 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett (MSFT)" Date: Mon, 26 Aug 2019 10:21:10 -0700 Subject: [PATCH] connection: start up the output thread _only after_ all the pipes are up (#2528) Fixes #2527 --- .../TerminalConnection/ConhostConnection.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/cascadia/TerminalConnection/ConhostConnection.cpp b/src/cascadia/TerminalConnection/ConhostConnection.cpp index a5bea4f608f..3da9d43f913 100644 --- a/src/cascadia/TerminalConnection/ConhostConnection.cpp +++ b/src/cascadia/TerminalConnection/ConhostConnection.cpp @@ -81,17 +81,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation extraEnvVars.emplace(L"WT_SESSION", pwszGuid); } - // Create our own output handling thread - // Each connection needs to make sure to drain the output from its backing host. - _hOutputThread.reset(CreateThread(nullptr, - 0, - StaticOutputThreadProc, - this, - 0, - nullptr)); - - THROW_LAST_ERROR_IF_NULL(_hOutputThread); - STARTUPINFO si = { 0 }; si.cb = sizeof(STARTUPINFOW); @@ -119,6 +108,18 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation si, extraEnvVars)); + // Create our own output handling thread + // This must be done after the pipes are populated. + // Each connection needs to make sure to drain the output from its backing host. + _hOutputThread.reset(CreateThread(nullptr, + 0, + StaticOutputThreadProc, + this, + 0, + nullptr)); + + THROW_LAST_ERROR_IF_NULL(_hOutputThread); + _connected = true; }