Repository navigation
fix: keepalive process inspection can hang after PowerShell exits - #1168
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 9:12 PM ET / August 26, 2026, 01:12 UTC. ClawSweeper reviewWhat this changesThis PR bounds PowerShell command-line output draining and routes setup and tray keepalive inspection through the shared helper so inherited stdout handles cannot hang local gateway recovery. Merge readinessKeep open. Current main and v2026.7.1 retain the unbounded output drain, while this actively landing branch supplies a focused bounded fix with Windows runtime evidence. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherGateway setup and tray keepalive inspect Windows process command lines to identify owned local gateway processes. The result feeds safe recovery, cleanup, and ownership decisions. flowchart LR
A[Tray keepalive] --> C[Command-line lookup]
B[Setup keepalive] --> C
C --> D[PowerShell CIM query]
D --> E{Process and stdout finish?}
E -->|yes| F[Command line]
E -->|timeout| G[Indeterminate result]
F --> H[Ownership and recovery]
G --> H
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the shared bounded lookup through the active landing path so setup, tray keepalive, and listener provenance all avoid an inherited-pipe hang. Do we have a high-confidence way to reproduce the issue? Yes, with high source confidence: a child that retains inherited stdout leaves current main waiting at the unbounded post-exit read; the PR also reports a real Windows parent and descendant exercise of that condition. Is this the best way to solve the issue? Yes. Centralizing the existing PowerShell/CIM lookup is the narrowest maintainable repair and preserves callers' established null-as-indeterminate behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c446f34882af. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
WaitForExit returns when PowerShell exits, but ReadToEnd only finishes after the write end of stdout closes. A descendant that inherited the pipe left GetResult hanging past the 5s timeout. Drain the leftover budget (same pattern as the MXC probe) and reuse the helper from setup and WSL keepalive copies. Signed-off-by: Sebastien Tardif <[email protected]>
0096a23 to
2a2cac6
Compare
Co-authored-by: Copilot App <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
What Problem This Solves
Fixes an issue where users starting or repairing a local Windows gateway could see the tray or setup wizard hang after PowerShell finished listing a process command line. The hang occurs when keepalive cleanup or port ownership inspection sees the PowerShell child exit while a descendant still holds the redirected stdout pipe.
Why This Change Was Made
The inspection waited five seconds for PowerShell to exit, then used an unbounded stdout read.
WaitForExitcompletes when the child exits, butReadToEndcompletes only after every inherited write handle closes. The shared helper now bounds both child exit and stdout drain, observes abandoned reads, releases the owned stdout reader, and records distinct trace diagnostics for process, exit-timeout, and drain-timeout failures.Tray keepalive and setup keepalive now use the same bounded command-line lookup instead of keeping separate implementations.
User Impact
Local gateway keepalive and setup process inspection return
null(indeterminate command line) instead of hanging when stdout never closes. Successful output that completes during the drain grace period is preserved.Evidence
Current-head Windows proof on
a2ff98889cd92b4d5b2040f7dbc7683f7f23d472:cmd.exeparent exited while aping.exedescendant retained stdout. The helper returnednullwithin two seconds instead of waiting for pipe EOF.WindowsTcpListenerSnapshot.GetProcessCommandLineand do not reintroduceStandardOutput.ReadToEnd.Change Type
Scope
winnodeValidation
The full validation tree included a normal merge of current
origin/mainbefore these commands, so the fix was exercised against the release-bound base without rewriting history.Real behavior proof
a2ff98889cd92b4d5b2040f7dbc7683f7f23d472.GetProcessCommandLine(Environment.ProcessId)exercised the real Windows PowerShell and CIM path and completed within the bounded window.Security Impact
No)No)No)No)No)Yes, explain the risk and mitigation:Compatibility and Migration
Yes)No)No)Review Conversations