Skip to content

Conversation

@o-sdn-o
Copy link

@o-sdn-o o-sdn-o commented Oct 4, 2025

PR Summary

Fix the long-known issue of duplicate output.

PR Context

When a console resize event is received, the event handler sets errno to EINTR, which falsely causes a concurrently pending write operation to be considered failed and retried. This results in duplicate console output, as well as duplicate application requests. This duplication can lead to an infinite loop, since a duplicate request generates another console resize event, which triggers another duplicate request. This can occur, for example, when terminals generate a resize event when an application requests a switch between alternate/normal buffer mode.

Fixes PowerShell/Win32-OpenSSH#2275 and most of related issues.

Related to:

…, and causes it to try again.

xlink directvt/vtm#819 (comment)

> When a window resize event is received (terminal generates WINDOW_BUFFER_SIZE_EVENT event when switching between alternate/normal buffer mode), the errno becomes EINTR which causes the write operation think its failed.

potentially fixes PowerShell/Win32-OpenSSH#2275
@o-sdn-o
Copy link
Author

o-sdn-o commented Oct 4, 2025

@microsoft-github-policy-service agree

@tgauth
Copy link
Collaborator

tgauth commented Oct 6, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@boomshankerx
Copy link

This is infuriating. It's interrupting my entire workflow. Please make this a priority.

@diffuty
Copy link

diffuty commented Oct 31, 2025

All checks seem to be passing.
Curious what blocks reviewers from giving this PR a look ?

@o-sdn-o o-sdn-o changed the title Fix the SIGWINCH interrupt makes the write operation think its failed, and causes it to try again Fix duplicate output on console resize event Nov 8, 2025
@o-sdn-o o-sdn-o marked this pull request as draft November 9, 2025 12:43
@o-sdn-o o-sdn-o marked this pull request as ready for review November 9, 2025 12:43
@tgauth tgauth requested a review from Copilot December 1, 2025 21:37
Copilot finished reviewing on behalf of tgauth December 1, 2025 21:39
Copy link

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

This PR fixes a long-standing issue where console resize events caused duplicate output in Win32-OpenSSH. The root cause was that the SIGWINCH signal handler was setting errno = EINTR, which caused concurrent write operations to be incorrectly treated as failed and retried, resulting in duplicate console output and application requests.

Key changes:

  • Modified signal processing to exclude W32_SIGWINCH from setting errno = EINTR, preventing false write operation failures
  • Removed the workaround code that attempted to consume the first WINDOW_BUFFER_SIZE_EVENT after entering raw mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
contrib/win32/win32compat/signal.c Added W32_SIGWINCH to the exclusion list for signals that should not set errno = EINTR, preventing write operations from being incorrectly interrupted
contrib/win32/win32compat/console.c Removed the workaround that consumed the first console resize event, as it's no longer needed with the signal handling fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@tgauth tgauth left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @o-sdn-o!

@tgauth tgauth merged commit 2586de1 into PowerShell:latestw_all Dec 1, 2025
10 checks passed
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.

Strange character sequences (ANSI escape sequences?) leaking into shell prompt when starting/attaching Tmux

4 participants