From 996d19740118903e96969441fe37f44859eb429a Mon Sep 17 00:00:00 2001 From: johba Date: Sun, 15 Mar 2026 10:39:40 +0100 Subject: [PATCH] fix: supervisor only kills factory-spawned claude, not interactive sessions pgrep matched all claude processes including manual screen sessions. Narrow to "claude -p" so only non-interactive (factory-spawned) processes get reaped by the stale-process cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) --- factory/factory-poll.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/factory/factory-poll.sh b/factory/factory-poll.sh index 62a682a..ded9691 100755 --- a/factory/factory-poll.sh +++ b/factory/factory-poll.sh @@ -71,8 +71,8 @@ SWAP_USED_MB=$(free -m | awk '/Swap:/{print $3}') if [ "${AVAIL_MB:-9999}" -lt 500 ] || { [ "${SWAP_USED_MB:-0}" -gt 3000 ] && [ "${AVAIL_MB:-9999}" -lt 2000 ]; }; then flog "MEMORY CRISIS: avail=${AVAIL_MB}MB swap_used=${SWAP_USED_MB}MB — auto-fixing" - # Kill stale claude processes (>3h old) - STALE_CLAUDES=$(pgrep -f "claude" --older 10800 2>/dev/null || true) + # Kill stale factory-spawned claude processes (>3h old) — skip interactive sessions + STALE_CLAUDES=$(pgrep -f "claude -p" --older 10800 2>/dev/null || true) if [ -n "$STALE_CLAUDES" ]; then echo "$STALE_CLAUDES" | xargs kill 2>/dev/null || true fixed "Killed stale claude processes: ${STALE_CLAUDES}" @@ -285,8 +285,8 @@ fi status "P4: housekeeping" -# Stale claude processes (>3h, not caught by P0) -STALE_CLAUDES=$(pgrep -f "claude" --older 10800 2>/dev/null || true) +# Stale factory-spawned claude processes (>3h, not caught by P0) — skip interactive sessions +STALE_CLAUDES=$(pgrep -f "claude -p" --older 10800 2>/dev/null || true) if [ -n "$STALE_CLAUDES" ]; then echo "$STALE_CLAUDES" | xargs kill 2>/dev/null || true fixed "Killed stale claude processes: $(echo $STALE_CLAUDES | wc -w) procs"