Terminal: Apply changes from upstream

The upstream github.com/microsoft/terminal did change the function
and the order in which the handles are closed. This updates our
copy of the function to follow those changes.

Change-Id: I9eceaa607e63ee4981d06ebc8f3b6920106247da
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2025-02-18 08:55:28 +01:00
parent fce61829b9
commit 890c99d739

View File

@@ -570,29 +570,21 @@ void _ClosePseudoConsoleMembers(_In_ PseudoConsole* pPty)
{
if (pPty != nullptr)
{
// See MSFT:19918626
// First break the signal pipe - this will trigger conhost to tear itself down
if (_HandleIsValid(pPty->hSignal))
{
CloseHandle(pPty->hSignal);
pPty->hSignal = nullptr;
}
// Then, wait on the conhost process before killing it.
// We do this to make sure the conhost finishes flushing any output it
// has yet to send before we hard kill it.
if (_HandleIsValid(pPty->hConPtyProcess))
{
CloseHandle(pPty->hConPtyProcess);
pPty->hConPtyProcess = nullptr;
}
// Then take care of the reference handle.
// TODO GH#1810: Closing the reference handle late leaves conhost thinking
// that we have an outstanding connected client.
if (_HandleIsValid(pPty->hPtyReference))
{
CloseHandle(pPty->hPtyReference);
pPty->hPtyReference = nullptr;
}
if (_HandleIsValid(pPty->hConPtyProcess))
{
CloseHandle(pPty->hConPtyProcess);
pPty->hConPtyProcess = nullptr;
}
}
}