Skip to content

CLI: fix gateway restart health ownership for child listener pids#24696

Merged
gumadeiras merged 3 commits intomainfrom
codex/gateway-restart-health-ownership
Feb 23, 2026
Merged

CLI: fix gateway restart health ownership for child listener pids#24696
gumadeiras merged 3 commits intomainfrom
codex/gateway-restart-health-ownership

Conversation

@gumadeiras
Copy link
Member

@gumadeiras gumadeiras commented Feb 23, 2026

Summary

  • fix restart-health ownership checks to treat listener child processes as owned by the running service pid
  • capture unix listener ppid in port inspection (ps -o ppid=) so restart checks can distinguish owned children from true stale listeners
  • add regression tests for child-owned listener vs non-owned listener behavior

Why

openclaw gateway restart could falsely report stale gateway processes and time out when the service manager pid and the socket-listener pid differ (parent/child model), which happens on both launchd and systemd setups.

Testing

  • pnpm test -- src/cli/daemon-cli/restart-health.test.ts src/cli/daemon-cli/lifecycle.test.ts src/infra/ports.test.ts
  • pnpm openclaw gateway restart
  • pnpm openclaw gateway restart --json

Greptile Summary

Fixed restart-health ownership checks to recognize child listener processes by capturing parent pid (ppid) from Unix ps output. The restart command previously timed out when the service manager pid differed from the socket-listener pid (parent/child model common in launchd and systemd setups). The fix adds ppid to PortListener, captures it via ps -o ppid=, and updates listenerOwnedByRuntimePid() to check both direct pid match and ppid match against the runtime pid.

Key changes:

  • Added ppid field to PortListener type
  • Implemented resolveUnixParentPid() to capture parent process ID on Unix systems
  • Updated listenerOwnedByRuntimePid() helper to check both listener.pid === runtimePid and listener.ppid === runtimePid
  • Added comprehensive test coverage for child-owned vs non-owned listener scenarios

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is focused, well-tested, and solves a specific bug without introducing side effects. The new ppid field is optional and backward-compatible. The logic correctly handles both direct ownership (pid match) and child process ownership (ppid match). Tests verify both the fixed scenario and the unchanged behavior for non-owned listeners.
  • No files require special attention

Last reviewed commit: a8d05ef

Copilot AI review requested due to automatic review settings February 23, 2026 18:30
@openclaw-barnacle openclaw-barnacle bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Feb 23, 2026
Copy link
Contributor

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

This PR fixes a bug in gateway restart health checks where the service could falsely report stale processes when using parent/child process models (common with launchd and systemd). The fix adds parent PID tracking to distinguish legitimately owned child listener processes from truly stale ones.

Changes:

  • Add ppid (parent process ID) field to PortListener type for tracking process parent relationships
  • Capture ppid during Unix port inspection via ps -o ppid= command
  • Update restart health ownership checks to recognize child processes (listener.ppid === runtime.pid) as owned
  • Add regression tests for child-owned vs non-owned listener scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/infra/ports-types.ts Adds optional ppid field to PortListener type
src/infra/ports-inspect.ts Implements resolveUnixParentPid function and integrates ppid lookup into listener inspection
src/cli/daemon-cli/restart-health.ts Adds listenerOwnedByRuntimePid helper and updates ownership/stale detection logic to check both pid and ppid
src/cli/daemon-cli/restart-health.test.ts Adds tests verifying child-owned listeners are healthy and non-owned listeners are marked stale

@gumadeiras gumadeiras force-pushed the codex/gateway-restart-health-ownership branch from d246b9c to d6d4b43 Compare February 23, 2026 18:52
@gumadeiras gumadeiras merged commit 5de1f54 into main Feb 23, 2026
5 checks passed
@gumadeiras gumadeiras deleted the codex/gateway-restart-health-ownership branch February 23, 2026 18:53
@gumadeiras
Copy link
Member Author

Merged via squash.

Thanks @gumadeiras!

iamjulio pushed a commit to NeuroGym-Dev/openclaw that referenced this pull request Feb 23, 2026
* upstream/main: (1467 commits)
  fix(doctor): use gateway health status for memory search key check (openclaw#22327)
  refactor: harden reset notice + cron delivery target flow
  refactor(exec): simplify env-prefixed wrapper modifier check
  fix(skills): support multiline frontmatter fallback without PyYAML
  fix(skills): make quick_validate work without PyYAML
  fix(exec): bind env-prefixed shell wrappers to full approval text
  fix(browser): derive relay auth token from gateway token in Chrome extension
  Browser relay: accept raw gateway token in extension auth
  fix(gateway): include platform and reason in node command rejection error
  CLI: fix gateway restart health ownership for child listener pids (openclaw#24696)
  docs: detail per-agent prompt caching configuration
  fix(config): tighten bedrock cache-retention type narrowing
  feat(agents): add per-agent stream params overrides for cache tuning (openclaw#17470) (thanks @rrenamed)
  fix(providers): support Bedrock Anthropic cacheRetention defaults/pass-through (openclaw#22303) (thanks @snese)
  fix(providers): disable Bedrock prompt caching for non-Anthropic models (openclaw#20866) (thanks @pierreeurope)
  docs(changelog): note /new and /reset auth-label removal (openclaw#24409)
  fix(reply): omit auth labels in /new and /reset
  docs(changelog): correct kimi issue references
  test(tools): fix kimi web_search mock typing
  feat(media): add moonshot video provider and wiring
  ...

# Conflicts:
#	ui/src/ui/app-render.ts
#	ui/src/ui/controllers/agents.ts
carlosrivera pushed a commit to myascendai/meshiclaw that referenced this pull request Feb 23, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
plgs2005 pushed a commit to plgs2005/openclaw that referenced this pull request Feb 24, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…enclaw#24696)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: d6d4b43
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants