feat(orphans): add --aggressive flag for tmux-verified orphan detection

The existing PPID=1 detection misses orphaned Claude processes that get
reparented to something other than init/launchd. The new --aggressive
flag cross-references Claude processes against active tmux sessions to
find ALL orphans not in any gt-* or hq-* session.

Testing shows this catches ~3x more orphans (117 vs 39 in one sample).

Usage:
  gt orphans procs --aggressive       # List ALL orphans
  gt orphans procs kill --aggressive  # Kill ALL orphans

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nux
2026-01-20 20:37:20 -08:00
committed by beads/crew/emma
parent 77ac332a41
commit 44d5b4fdd2
2 changed files with 181 additions and 11 deletions

View File

@@ -18,6 +18,23 @@ type CleanupResult struct {
Error error
}
// ZombieProcess represents a claude process not in any active tmux session.
// On Windows, zombie cleanup is not supported, so this is a stub definition.
type ZombieProcess struct {
PID int
Cmd string
Age int // Age in seconds
TTY string // TTY column from ps
}
// ZombieCleanupResult describes what happened to a zombie process.
// On Windows, cleanup is a no-op.
type ZombieCleanupResult struct {
Process ZombieProcess
Signal string // "SIGTERM", "SIGKILL", or "UNKILLABLE"
Error error
}
// FindOrphanedClaudeProcesses is a Windows stub.
func FindOrphanedClaudeProcesses() ([]OrphanedProcess, error) {
return nil, nil
@@ -27,3 +44,13 @@ func FindOrphanedClaudeProcesses() ([]OrphanedProcess, error) {
func CleanupOrphanedClaudeProcesses() ([]CleanupResult, error) {
return nil, nil
}
// FindZombieClaudeProcesses is a Windows stub.
func FindZombieClaudeProcesses() ([]ZombieProcess, error) {
return nil, nil
}
// CleanupZombieClaudeProcesses is a Windows stub.
func CleanupZombieClaudeProcesses() ([]ZombieCleanupResult, error) {
return nil, nil
}