Skip to content

Fixes #5442. Windows VT input can hang during shutdown when ReadFile is blocked#5443

Merged
BDisp merged 1 commit into
gui-cs:developfrom
BDisp:issue/5442_input-hang-when-readfile-blocked
May 28, 2026
Merged

Fixes #5442. Windows VT input can hang during shutdown when ReadFile is blocked#5443
BDisp merged 1 commit into
gui-cs:developfrom
BDisp:issue/5442_input-hang-when-readfile-blocked

Conversation

@BDisp
Copy link
Copy Markdown
Collaborator

@BDisp BDisp commented May 28, 2026

Fixes

Proposed Changes/Todos

  • Add CancelIoEx API

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@BDisp BDisp requested a review from tig as a code owner May 28, 2026 18:52
@tig tig requested a review from Copilot May 28, 2026 19:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Windows shutdown hang where the ANSI driver's input thread could be stuck inside synchronous ReadFile. Adds a CancelIoEx-based wake helper invoked during AnsiOutput.Dispose, and treats ERROR_OPERATION_ABORTED from ReadFile as normal cancellation rather than a warning.

Changes:

  • Add CancelIoEx P/Invoke and a static WakePendingRead() helper on WindowsVTInputHelper.
  • Silently treat ERROR_OPERATION_ABORTED (995) from ReadFile as a benign cancellation.
  • Call WakePendingRead() from AnsiOutput.Dispose when running on the WindowsVT platform.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Terminal.Gui/Drivers/WindowsHelpers/WindowsVTInputHelper.cs Adds CancelIoEx interop, error constants, WakePendingRead() helper, and handles ERROR_OPERATION_ABORTED in TryRead.
Terminal.Gui/Drivers/AnsiDriver/AnsiOutput.cs Invokes WindowsVTInputHelper.WakePendingRead() during dispose on the WindowsVT platform to unblock pending reads.

Copy link
Copy Markdown
Member

@tig tig left a comment

Choose a reason for hiding this comment

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

lgtm

@BDisp BDisp merged commit c9a0513 into gui-cs:develop May 28, 2026
13 checks passed
@BDisp BDisp deleted the issue/5442_input-hang-when-readfile-blocked branch May 28, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows VT input can hang during shutdown when ReadFile is blocked

3 participants