Lock and Unlock in conhost should decouple Ctrl+C dispatch and use smarter handling #2986

Open
opened 2026-01-30 23:10:17 +00:00 by claunia · 3 comments
Owner

Originally created by @miniksa on GitHub (Jul 29, 2019).

The Lock and Unlock procedures in Conhost.exe are fraught with error.

For one, we are using intricate details of how many recursive entries there are on the lock to count when it is fully unlocked and dispatch Ctrl+C events. We're not supposed to be dependent on the lock count at all.

Additionally, there's multiple layers at which the locks can be processed, some of which DO dispatch the Ctrl+C events on the last unlock and some of which do NOT.

Finally, the lock/unlock procedure is bad in that it is easy to not unlock something since it's not in any sort of smart RAII-type object. This is sort of mitigated by wil::scope_exit in many places, but that function is also discouraged when you can use something better.

This issue encompasses rooting around and finding a better overall way to do all of this.

It does NOT encompass more granular locks than already exist.

Originally created by @miniksa on GitHub (Jul 29, 2019). The Lock and Unlock procedures in Conhost.exe are fraught with error. For one, we are using intricate details of how many recursive entries there are on the lock to count when it is fully unlocked and dispatch Ctrl+C events. We're not supposed to be dependent on the lock count at all. Additionally, there's multiple layers at which the locks can be processed, some of which DO dispatch the Ctrl+C events on the last unlock and some of which do NOT. Finally, the lock/unlock procedure is bad in that it is easy to not unlock something since it's not in any sort of smart RAII-type object. This is sort of mitigated by wil::scope_exit in many places, but that function is also discouraged when you can use something better. This issue encompasses rooting around and finding a better overall way to do all of this. It does NOT encompass more granular locks than already exist.
claunia added the Product-ConhostIssue-TaskArea-Server labels 2026-01-30 23:10:18 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 29, 2019):

where's the "crying inside" reaction when you need it

@zadjii-msft commented on GitHub (Jul 29, 2019): where's the "crying inside" reaction when you need it
Author
Owner

@miniksa commented on GitHub (Jul 29, 2019):

🤪

@miniksa commented on GitHub (Jul 29, 2019): 🤪
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 29, 2019):

Yanking triage ;P

@DHowett-MSFT commented on GitHub (Jul 29, 2019): Yanking triage ;P
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2986