[release/v7.6] Close pipe client handles after creating the child ssh process by adityapatwardhan · Pull Request #26564 · PowerShell/PowerShell
Backport of #26491 to release/v7.6
Triggered by @adityapatwardhan on behalf of @daxian-dbw
Original CL Label: CL-General
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
- Required tooling change
- Optional tooling change (include reasoning)
Customer Impact
- Customer reported
- Found internally
Fixes critical SSH connection hangs on Windows. When running Invoke-Command -HostName or New-PSSession -HostName on Windows, PowerShell would hang indefinitely due to pipe client handles not being closed after creating the ssh.exe process. This prevents the stdout/stderr reader threads from completing when SSH exits.
Regression
REQUIRED: Check exactly one box.
- Yes
- No
This is not a regression.
Testing
Original PR added tests to verify PowerShell doesn't hang on SSH connections to non-existent hosts. Backport verified by running the new tests on release/v7.6 branch and confirming the fix resolves the Windows-specific SSH hang issue.
Risk
REQUIRED: Check exactly one box.
- High
- Medium
- Low
Medium risk - affects SSH remoting functionality which is commonly used, but the fix is well-scoped to handle cleanup and has comprehensive test coverage. The change only affects the Windows-specific SSH connection code path.