Skip to content

Fix signal handling trap for xauth in Windows#843

Open
Tal500 wants to merge 3 commits intoPowerShell:latestw_allfrom
Tal500:fix-sigint-signal-for-xauth
Open

Fix signal handling trap for xauth in Windows#843
Tal500 wants to merge 3 commits intoPowerShell:latestw_allfrom
Tal500:fix-sigint-signal-for-xauth

Conversation

@Tal500
Copy link
Copy Markdown

@Tal500 Tal500 commented Apr 23, 2026

This fixes PowerShell/Win32-OpenSSH#1803. I'm sure that merging this PR will make the folks very happy, as this issue is very old even though the fix is easy.

I used codex for coding, but I verified and fixed its code.
By compiling (in Windows 11, x64, Release) this codebase both before my change and after, I have reproduced the bug before my change and verified that it fixed after the change.

More testing details - tested on windows terminal (wt) under a with the shell of "Command Prompt", connected to this project SSH with the "-Y" flag, and the X11 server I used is VcXsrv.

Technical Reasoning

Before

xauth was launched via system/popen, making it accept the process signals from outside (such as sigint, i.e. Ctrl+C), interfearing with the Ctrl+C signal that the user wants to send to the actual running process in the terminal.

After

Ensure xauth invocations on Windows use a consistent subprocess path and argument handling instead of system/popen, avoiding console/signal issues and enabling proper stdout capture and exit-status checks.

Description

  • Add a helper client_x11_run_xauth_for_windows that launches xauth via the existing subprocess API with consistent flags and optional stdout capture.
  • Replace Windows system/popen usage in client_x11_get_proto with argument-list based calls that use the new helper for both generate and list code paths and parse captured output.

@Tal500
Copy link
Copy Markdown
Author

Tal500 commented Apr 23, 2026

@microsoft-github-policy-service agree

Copy link
Copy Markdown

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

Adjusts Windows X11 forwarding’s xauth invocation to avoid console/signal propagation issues by replacing system()/popen() usage with the existing subprocess() API.

Changes:

  • Added a Windows-only helper to run xauth via subprocess() with consistent flags and optional stdout capture.
  • Replaced system() call for xauth generate with argument-vector + waitpid() handling on Windows.
  • Replaced popen() call for xauth list with stdout-capturing subprocess execution and output parsing on Windows.

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

Comment thread clientloop.c
Comment thread clientloop.c
Copy link
Copy Markdown
Author

@Tal500 Tal500 left a comment

Choose a reason for hiding this comment

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

I implemented the copilot suggestions

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.

Using CTRL+C in an SSH session with X11 forwarding and XAuthLocation set will cause ssh to terminate with error

2 participants