Skip to content

fix(infra): gateway pid probe no longer hangs when ps sampling stalls - #109731

Merged
steipete merged 3 commits into
openclaw:mainfrom
xydt-juyaohui:fix/gateway-process-probe-kill-signal
Jul 17, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
xydt-juyaohui:fix/gateway-process-probe-kill-signal

Conversation

@xydt-juyaohui

Copy link
Copy Markdown
Contributor

What Problem This Solves

readGatewayProcessArgsSync (in src/infra/gateway-processes.ts) probes ps on darwin to read a gateway process's argv before signaling it or reporting it as a verified listener PID. The darwin branch already passed a 1000ms timeout, but {BT}spawnSync{BT} defaults killSignal to SIGTERM, which an unresponsive or hung ps child can ignore. As a result a stalled ps probe can keep the gateway process blocked past the configured timeout, hanging gateway signal verification and listener PID discovery.

This is the same class of stall already fixed for the doctor TUI process probe in #109243, applied to the gateway's own pid-verification path.

Evidence

  • The fix adds killSignal: "SIGKILL" to the spawnSync("ps", ...) call so a stalled probe is reaped at the deadline instead of hanging, and extracts the timeout into a named GATEWAY_PS_PROBE_TIMEOUT_MS constant.
  • Local vitest run of src/infra/gateway-processes.test.ts is green: 8 passed (8), including the darwin path.
  • The darwin test now asserts the full spawnSync options shape - encoding, killSignal, timeout - locking in the behavior (mirrors the assertion added in fix(doctor): doctor no longer hangs when TUI process sampling stalls #109243).
const ps = spawnSync("ps", ["-o", "command=", "-p", String(pid)], {
  encoding: "utf8",
  killSignal: "SIGKILL",
  timeout: GATEWAY_PS_PROBE_TIMEOUT_MS,
});
 Test Files  1 passed (1)
      Tests  8 passed (8)

Siblings of the same series (already merged, same spawnSync + killSignal: SIGKILL shape): #109243 (doctor WhatsApp responsiveness / TUI process sampling), #109458 (footer git probe).

readGatewayProcessArgsSync probes ps to verify gateway argv before
signaling or reporting listener PIDs. The darwin branch already passed
timeout: 1000, but spawnSync defaults killSignal to SIGTERM, which an
unresponsive or hung ps child can ignore and keep the gateway process
blocked past the timeout.

Force killSignal: SIGKILL (matching the doctor probe fix in openclaw#109243) so
a stalled ps probe is reaped at the deadline instead of hanging gateway
signal verification and listener PID discovery.

Extract GATEWAY_PS_PROBE_TIMEOUT_MS for the named timeout and assert the
full spawnSync options (encoding / killSignal / timeout) in the darwin
test.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 5:08 AM ET / 09:08 UTC.

Summary
Centralizes four bounded Unix ps probes behind a shared spawnSync helper that uses SIGKILL on timeout and updates caller assertions.

PR surface: Source +5, Tests +14. Total +19 across 7 files.

Reproducibility: no. high-confidence live current-main reproduction is included. The source path makes the stall reproducible by contract, but the submitted evidence is limited to mocked unit assertions.

Review metrics: 1 noteworthy metric.

  • Bounded process probes: 4 call sites centralized. The final scope is broader than the title’s gateway path, so maintainers should review the shared invariant across doctor and stale-process detection too.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-whatsapp-responsiveness.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #109731
Summary: This PR is the canonical remaining ps-probe centralization; the merged doctor PR shares its root cause, while the git-footer PR is adjacent synchronous-process hardening.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal or live-output proof using a real ps substitute that ignores the normal termination signal, showing the gateway probe returns near one second.
  • Resolve the current main conflicts and rerun the focused gateway, doctor, and stale-process tests on the refreshed head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR shows mocked Vitest assertions but no after-fix real stalled-process run; add redacted terminal, live-output, or log evidence showing return near the timeout, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The PR does not demonstrate that a real signal-ignoring ps process is reaped near the configured deadline on the gateway path; mocked option assertions cannot prove the observed hang is removed.
  • [P1] The head is currently conflict-marked against main, so the final helper and all four caller conversions require review again after conflict resolution.
  • [P1] The second commit broadens the original gateway-only fix to four production probes; focused tests should be rerun on the refreshed head to confirm healthy-output parsing remains unchanged.

Maintainer options:

  1. Decide the mitigation before merge
    Refresh the branch, retain one shared bounded ps helper, and add redacted terminal or live-output proof showing a signal-ignoring probe returns near its deadline while normal ps output still parses unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No code defect is suitable for automated repair; the contributor should supply real stalled-process proof and refresh the conflict-marked branch before ordinary maintainer review.

Security
Cleared: The diff adds no dependency, workflow, permission, secret, download, package-resolution, or untrusted code-execution change; it only tightens termination of fixed-argument local ps probes.

Review details

Best possible solution:

Refresh the branch, retain one shared bounded ps helper, and add redacted terminal or live-output proof showing a signal-ignoring probe returns near its deadline while normal ps output still parses unchanged.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live current-main reproduction is included. The source path makes the stall reproducible by contract, but the submitted evidence is limited to mocked unit assertions.

Is this the best way to solve the issue?

Yes, the shared helper is the narrowest maintainable fix because it centralizes the timeout-kill invariant instead of leaving one-off options at each ps call; proof and conflict resolution remain merge gates rather than design defects.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ff4f0161fca.

Label changes

Label justifications:

  • P2: This is a bounded availability improvement for uncommon stalled local process sampling, with limited blast radius and no demonstrated widespread outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR shows mocked Vitest assertions but no after-fix real stalled-process run; add redacted terminal, live-output, or log evidence showing return near the timeout, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +5, Tests +14. Total +19 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 24 19 +5
Tests 3 16 2 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 40 21 +19

What I checked:

Likely related people:

  • steipete: Authored the current head’s centralization of bounded ps probes, making them the clearest routing candidate for the shared-helper boundary. (role: branch refactor author and adjacent owner; confidence: high; commits: dd388b77f906; files: src/infra/spawn-ps.ts, src/infra/gateway-processes.ts, src/infra/restart-stale-pids.ts)
  • mushuiyu886: Authored the doctor-path change that established the same SIGKILL timeout pattern and supplied real-process timing proof. (role: introduced the merged sibling behavior; confidence: high; commits: 5562e6b267c8, 9edd66274187; files: src/commands/doctor-whatsapp-responsiveness.ts, src/commands/doctor-whatsapp-responsiveness.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-07-17T06:55:28.220Z sha 533f1ef :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T07:38:43.264Z sha 533f1ef :: needs real behavior proof before merge. :: none

Co-authored-by: 琚耀辉0668001366 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S and removed size: XS labels Jul 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed commands Command implementations size: S labels Jul 17, 2026
@steipete
steipete merged commit 89780d5 into openclaw:main Jul 17, 2026
118 of 122 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
…openclaw#109731)

* fix(infra): gateway pid probe no longer hangs when ps sampling stalls

readGatewayProcessArgsSync probes ps to verify gateway argv before
signaling or reporting listener PIDs. The darwin branch already passed
timeout: 1000, but spawnSync defaults killSignal to SIGTERM, which an
unresponsive or hung ps child can ignore and keep the gateway process
blocked past the timeout.

Force killSignal: SIGKILL (matching the doctor probe fix in openclaw#109243) so
a stalled ps probe is reaped at the deadline instead of hanging gateway
signal verification and listener PID discovery.

Extract GATEWAY_PS_PROBE_TIMEOUT_MS for the named timeout and assert the
full spawnSync options (encoding / killSignal / timeout) in the darwin
test.

* refactor: centralize bounded ps probes

Co-authored-by: 琚耀辉0668001366 <[email protected]>

* refactor: leave doctor ps hardening to main

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…openclaw#109731)

* fix(infra): gateway pid probe no longer hangs when ps sampling stalls

readGatewayProcessArgsSync probes ps to verify gateway argv before
signaling or reporting listener PIDs. The darwin branch already passed
timeout: 1000, but spawnSync defaults killSignal to SIGTERM, which an
unresponsive or hung ps child can ignore and keep the gateway process
blocked past the timeout.

Force killSignal: SIGKILL (matching the doctor probe fix in openclaw#109243) so
a stalled ps probe is reaped at the deadline instead of hanging gateway
signal verification and listener PID discovery.

Extract GATEWAY_PS_PROBE_TIMEOUT_MS for the named timeout and assert the
full spawnSync options (encoding / killSignal / timeout) in the darwin
test.

* refactor: centralize bounded ps probes

Co-authored-by: 琚耀辉0668001366 <[email protected]>

* refactor: leave doctor ps hardening to main

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants