[PR #18588] ConPTY: Fix shutdown if killed during startup #31562

Open
opened 2026-01-31 09:48:02 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/18588

State: closed
Merged: Yes


During startup we relinquish ownership of the console lock to wait for the DA1 response of the hosting terminal. The problem occurs if the hosting terminal disconnects during that time. The broken pipe will cause VtIo to send out CTRL_CLOSE_EVENT messages, but those won't achieve anything, because the first and only client hasn't even finished connecting yet. What we need to do instead is to return an error code.

In order to not use a bunch of booleans to control this behavior, I gave VtIo a state enum. This however required restructuring the calling code in order to not have a dozen states.

Validation Steps Performed

  • Launch cmd.exe with ConPTY
  • ...but leave the stdin pipe unbound (which will hang the DA1 request)
  • Immediately kill the ConPTY session
  • cmd.exe exits after clicking away the error message
**Original Pull Request:** https://github.com/microsoft/terminal/pull/18588 **State:** closed **Merged:** Yes --- During startup we relinquish ownership of the console lock to wait for the DA1 response of the hosting terminal. The problem occurs if the hosting terminal disconnects during that time. The broken pipe will cause `VtIo` to send out `CTRL_CLOSE_EVENT` messages, but those won't achieve anything, because the first and only client hasn't even finished connecting yet. What we need to do instead is to return an error code. In order to not use a bunch of booleans to control this behavior, I gave `VtIo` a state enum. This however required restructuring the calling code in order to not have a dozen states. ## Validation Steps Performed * Launch cmd.exe with ConPTY * ...but leave the stdin pipe unbound (which will hang the DA1 request) * Immediately kill the ConPTY session * cmd.exe exits after clicking away the error message ✅
claunia added the pull-request label 2026-01-31 09:48:02 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31562