← back to Yolo Agent
fix: pgrep -c flag missing on macOS BSD pgrep (was flooding error log)
4bf7765cdb6168055cd6a4ceabb15f925e96fed3 · 2026-05-13 17:40:24 -0700 · SteveStudio2
The getRunningClaudeCount() circuit-breaker used 'pgrep -c -f' which
worked on GNU/Linux but exits 2 with 'usage: pgrep' on macOS, since
BSD pgrep has no count flag. The count was always returning 0 via
the catch-block, silently disabling the concurrency circuit breaker,
and producing ~76 'usage: pgrep' lines per session in
~/.pm2/logs/yolo-agent-error.log.
Replace with portable 'pgrep -f ... ' + line count in JS, and
redirect stderr to /dev/null via stdio so any future pgrep stderr
output doesn't pollute pm2 logs.
Files touched
Diff
commit 4bf7765cdb6168055cd6a4ceabb15f925e96fed3
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date: Wed May 13 17:40:24 2026 -0700
fix: pgrep -c flag missing on macOS BSD pgrep (was flooding error log)
The getRunningClaudeCount() circuit-breaker used 'pgrep -c -f' which
worked on GNU/Linux but exits 2 with 'usage: pgrep' on macOS, since
BSD pgrep has no count flag. The count was always returning 0 via
the catch-block, silently disabling the concurrency circuit breaker,
and producing ~76 'usage: pgrep' lines per session in
~/.pm2/logs/yolo-agent-error.log.
Replace with portable 'pgrep -f ... ' + line count in JS, and
redirect stderr to /dev/null via stdio so any future pgrep stderr
output doesn't pollute pm2 logs.
---
server.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 9f567c0..0155dcc 100644
--- a/server.js
+++ b/server.js
@@ -202,8 +202,9 @@ function archiveTask(taskFile, result) {
function getRunningClaudeCount() {
try {
const { execFileSync } = require('child_process');
- const out = execFileSync('/usr/bin/pgrep', ['-c', '-f', 'claude --print'], { encoding: 'utf8', timeout: 5000 });
- return parseInt(out.trim()) || 0;
+ // macOS BSD pgrep has no -c (count) flag; counting lines in JS works on both BSD and GNU pgrep.
+ const out = execFileSync('/usr/bin/pgrep', ['-f', 'claude --print'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
+ return out.trim().split('\n').filter(Boolean).length;
} catch (e) { return 0; }
}
← d0902e9 snapshot: 93 file(s) changed, +45 new, ~48 modified
·
back to Yolo Agent
·
untrack logs/*.log (junk); keep tasks/done history 574b0e6 →