Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConPTY: Fix shutdown if killed during startup #18588

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Feb 18, 2025

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 ✅

@lhecker lhecker added Product-Conpty For console issues specifically related to conpty Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. labels Feb 18, 2025
if (_state != State::Starting)
{
// Here's where we _could_ call CloseConsoleProcessState(), but this function
// only gets get called once when the first client connects and CONSOLE_INITIALIZED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// only gets get called once when the first client connects and CONSOLE_INITIALIZED
// only gets called once when the first client connects and CONSOLE_INITIALIZED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants