ClosePseudoConsole does not close the process handle to conhost #22263

Open
opened 2026-01-31 08:08:14 +00:00 by claunia · 0 comments
Owner

Originally created by @asmichi on GitHub (Sep 11, 2024).

Windows Terminal version

N/A

Windows build number

10.0.22631.4037 (Windows 11 Pro, 23H2)

Other Software

(None, just Kernel32)

Steps to reproduce

Run the EchoCon sample and observe its handles before/after the ClosePseudoConsole call.

  • Add a breakpoint at ClosePseudoConsole(hPC)
  • Start debugging
  • Run handle.exe -p EchoCon.exe -a | findstr Process when the program breaks at ClosePseudoConsole(hPC)
  • Step over
  • Run handle.exe -p EchoCon.exe -a | findstr Process

Expected Behavior

ClosePseudoConsole closes the handle to conhost.exe.

Actual Behavior

ClosePseudoConsole does not close the handle to conhost.exe (leaks the handle).

This looks like a Kernel32 version of #8706.

D:\>REM break just before ClosePseudoConsole(hPC)

D:\>handle -p EchoCon.exe -a | findstr Process
   E0: Process       conhost.exe(34388)

D:\>REM step over ClosePseudoConsole(hPC)

D:\>handle -p EchoCon.exe -a | findstr Process
   E0: Process       <Nonexistent process>(34388)
Originally created by @asmichi on GitHub (Sep 11, 2024). ### Windows Terminal version N/A ### Windows build number 10.0.22631.4037 (Windows 11 Pro, 23H2) ### Other Software (None, just Kernel32) ### Steps to reproduce Run the `EchoCon` sample and observe its handles before/after the `ClosePseudoConsole` call. - Add a breakpoint at `ClosePseudoConsole(hPC)` - Start debugging - Run `handle.exe -p EchoCon.exe -a | findstr Process` when the program breaks at `ClosePseudoConsole(hPC)` - Step over - Run `handle.exe -p EchoCon.exe -a | findstr Process` ### Expected Behavior `ClosePseudoConsole` closes the handle to conhost.exe. ### Actual Behavior `ClosePseudoConsole` does not close the handle to conhost.exe (leaks the handle). This looks like a Kernel32 version of #8706. ``` D:\>REM break just before ClosePseudoConsole(hPC) D:\>handle -p EchoCon.exe -a | findstr Process E0: Process conhost.exe(34388) D:\>REM step over ClosePseudoConsole(hPC) D:\>handle -p EchoCon.exe -a | findstr Process E0: Process <Nonexistent process>(34388) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22263