fix: orphan-processes check only detects Gas Town processes
Changed findRuntimeProcesses() to only detect Claude processes that have the --dangerously-skip-permissions flag. This is the signature of Gas Town managed processes - user's personal Claude sessions don't use this flag. Prevents false positives when users have personal Claude sessions running. Closes #611 Co-Authored-By: dwsmith1983 <dwsmith1983@users.noreply.github.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
f4072e58cc
commit
05ea767149
@@ -5,7 +5,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/steveyegge/gastown/internal/events"
|
"github.com/steveyegge/gastown/internal/events"
|
||||||
@@ -388,40 +387,41 @@ func (c *OrphanProcessCheck) getTmuxSessionPIDs() (map[int]bool, error) { //noli
|
|||||||
return pids, nil
|
return pids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findRuntimeProcesses finds all running runtime CLI processes.
|
// findRuntimeProcesses finds Gas Town Claude processes (those with --dangerously-skip-permissions).
|
||||||
// Excludes Claude.app desktop application and its helpers.
|
// Only detects processes started by Gas Town, not user's personal Claude sessions.
|
||||||
func (c *OrphanProcessCheck) findRuntimeProcesses() ([]processInfo, error) {
|
func (c *OrphanProcessCheck) findRuntimeProcesses() ([]processInfo, error) {
|
||||||
var procs []processInfo
|
var procs []processInfo
|
||||||
|
|
||||||
// Use ps to find runtime processes
|
// Use ps with args to get full command line (needed to check for Gas Town signature)
|
||||||
out, err := exec.Command("ps", "-eo", "pid,ppid,comm").Output()
|
out, err := exec.Command("ps", "-eo", "pid,ppid,args").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regex to match runtime CLI processes (not Claude.app)
|
|
||||||
// Match: "claude", "claude-code", or "codex" (or paths ending in those)
|
|
||||||
runtimePattern := regexp.MustCompile(`(?i)(^claude$|/claude$|^claude-code$|/claude-code$|^codex$|/codex$)`)
|
|
||||||
|
|
||||||
// Pattern to exclude Claude.app and related desktop processes
|
|
||||||
excludePattern := regexp.MustCompile(`(?i)(Claude\.app|claude-native|chrome-native)`)
|
|
||||||
|
|
||||||
for _, line := range strings.Split(string(out), "\n") {
|
for _, line := range strings.Split(string(out), "\n") {
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
if len(fields) < 3 {
|
if len(fields) < 3 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if command matches runtime CLI
|
// Extract command name (without path)
|
||||||
cmd := strings.Join(fields[2:], " ")
|
cmd := fields[2]
|
||||||
|
if idx := strings.LastIndex(cmd, "/"); idx >= 0 {
|
||||||
|
cmd = cmd[idx+1:]
|
||||||
|
}
|
||||||
|
|
||||||
// Skip desktop app processes
|
// Only match claude/codex processes, not tmux or other launchers
|
||||||
if excludePattern.MatchString(cmd) {
|
// (tmux command line may contain --dangerously-skip-permissions as part of the launched command)
|
||||||
|
if cmd != "claude" && cmd != "claude-code" && cmd != "codex" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only match CLI runtime processes
|
// Get full args
|
||||||
if !runtimePattern.MatchString(cmd) {
|
args := strings.Join(fields[2:], " ")
|
||||||
|
|
||||||
|
// Only match Gas Town Claude processes (have --dangerously-skip-permissions)
|
||||||
|
// This excludes user's personal Claude sessions
|
||||||
|
if !strings.Contains(args, "--dangerously-skip-permissions") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +436,7 @@ func (c *OrphanProcessCheck) findRuntimeProcesses() ([]processInfo, error) {
|
|||||||
procs = append(procs, processInfo{
|
procs = append(procs, processInfo{
|
||||||
pid: pid,
|
pid: pid,
|
||||||
ppid: ppid,
|
ppid: ppid,
|
||||||
cmd: cmd,
|
cmd: args,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user