Skip to content

Fix ssh-agent process detection on Cygwin and MSYS2 - #276

Closed
fmrns wants to merge 4 commits into
danielrobbins:masterfrom
fmrns:fix/msys-process-list
Closed

fmrns wants to merge 4 commits into
danielrobbins:masterfrom
fmrns:fix/msys-process-list

Conversation

@fmrns

@fmrns fmrns commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

The process-listing command used by Keychain 3.0.8 is incompatible with MSYS2's ps. As a result, Keychain fails to recognize running ssh-agent processes and starts additional agents.

On MSYS2 UCRT64, importing the released keychain-3.0.8.pyz reports:

<Platform cygwin supported=True>

Its process-listing command fails:

$ ps -A -o pid= -o uid= -o comm=
ps: unknown option -- A
Try `ps --help' for more information.
exit=1

Keychain discards that stderr and treats the process list as empty. Repeated invocation was observed to report:

Starting ssh-agent (previous pidfile stale: pid is not ssh-agent)...

and leave multiple ssh-agent processes running.

This change uses ps -e -l on Cygwin/MSYS and extracts the PID, numeric UID, and command while accounting for the status character and the fixed-width STIME field. Other platforms retain the existing command.

Regression tests cover UID filtering, status characters, paths containing spaces, command-name matching, and both time and date forms of STIME.

Validation:

  • MSYS2: tests/test_runtime.py — 39 passed.
  • Manual MSYS2 test: the patched checkout started an agent, then reused PID 1545 on the next invocation, with exit status 0 on both runs.
  • git diff --check passed.
  • Cygwin behavior was checked against its ps source; execution on Cygwin was not tested.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T07:49:44.491071Z 460595f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielrobbins

Copy link
Copy Markdown
Owner

Thank you for the PR. I will review this.

danielrobbins added a commit that referenced this pull request Nov 5, 2026
Include the original PR number and Fumiyuki Shimizu's GitHub handle.
The release branch includes the fix with additional robustness work and tests.

Closes #276.
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.

2 participants