Skip to content

macOS: Session discovery fails - pgrep -af does not output command line #1

@bbsngg

Description

@bbsngg

Bug Description

ClawChain cannot discover any Codex/Claude Code sessions on macOS. The dashboard shows zero session cards despite active Codex processes running.

Root Cause

In clawchain/host_monitor.py, the _scan_processes_via_pgrep() function uses pgrep -af . to scan running processes. On Linux, this outputs PID full_command_line, but on macOS the -a flag is not supported the same way — it only outputs bare PIDs (e.g., 1, 192, 35024).

Since _matches_agent() tries to regex-match agent patterns (like codex) against these lines, it never finds a match because the lines contain only numbers.

# Current code — works on Linux, broken on macOS
probe = subprocess.run(
    ["pgrep", "-af", "."],
    capture_output=True, text=True, check=False,
)

macOS pgrep -af . output:

1
192
35024
35025

Linux pgrep -af . output:

35024 node /usr/bin/codex
35025 codex resume

Environment

  • macOS Darwin 25.3.0 (arm64)
  • GNU bash 3.2.57
  • Python 3.12
  • ClawChain 0.1.0

Suggested Fix

Replace pgrep -af . with ps -eo pid,args, which outputs PID + full command line on both macOS and Linux. Keep pgrep as a fallback if ps is unavailable.

Steps to Reproduce

  1. Install ClawChain on macOS
  2. Start a Codex session
  3. Run the setup script and open the dashboard
  4. Observe that no sessions appear despite ps aux | grep codex showing running processes

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions