mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-24 10:58:37 +00:00
* fix(acpx): detect wrapper orphan on any PPID change, not just init reparenting The codex / claude adapter wrapper's orphan watcher (emitted by buildAdapterWrapperScript) skipped cleanup when `process.ppid !== 1`, intending to wait for the kernel to reparent the orphaned wrapper to PID 1 (init). This only works on bare-metal hosts without an active user-session manager. On systemd-managed deployments (EC2 user services, most container runtimes), an orphaned process is reparented to the user-session manager or container init — not to init itself. The watcher therefore never fires, and when the gateway exits, the adapter wrapper survives and holds its child process group (codex-acp.js + native binary) running indefinitely. Real-world symptom: each gateway restart accumulates 3-process trees of leftover codex adapters. Subsequent ACP spawns then contend with these orphans, the main event loop is starved by acpx-runtime reap attempts, and new sessions stall at "waiting for tool execution" for minutes. Fix: trigger orphan cleanup as soon as PPID changes from the recorded original, regardless of what the new PPID is. The killChildTree path already covers process-group cleanup via `kill(-pid, SIGTERM)`, so once the watcher fires, grandchildren are reaped correctly. Adds a regression test asserting the wrapper template does not re-introduce the `process.ppid !== 1` guard. * test: document maturity ref handoff --------- Co-authored-by: t2wei <t2wei@me.com> Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com>