Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions clawchain/host_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,15 +1068,25 @@ def _scan_processes_via_tasklist() -> list[str] | None:
def _scan_processes_via_pgrep() -> list[str]:
if os.name == "nt":
return []
# On macOS, pgrep -af does not print the full command line (only PIDs).
# Use "ps -eo pid,args" instead, which works on both macOS and Linux.
try:
probe = subprocess.run(
["pgrep", "-af", "."],
["ps", "-eo", "pid,args"],
capture_output=True,
text=True,
check=False,
)
except OSError:
return []
try:
probe = subprocess.run(
["pgrep", "-af", "."],
capture_output=True,
text=True,
check=False,
)
except OSError:
return []
if probe.returncode not in (0, 1):
return []
return [line.strip() for line in probe.stdout.splitlines() if line.strip()]
Expand Down