procscan

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package procscan discovers live `claude` sessions and the account each is bound to, by reading process environments. On macOS 26 `ps -Eww` prints the environment of same-user processes (verified on the target machine), which exposes CLAUDE_CONFIG_DIR.

A claude process with no CLAUDE_CONFIG_DIR in its environment is using the canonical ~/.claude dir, i.e. acct-00 (this is how plain `claude` sessions are attributed).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlivePIDs

func AlivePIDs(sessions []Session) map[int]bool

AlivePIDs returns the set of pids currently present, for session reconciliation.

func CountByConfigDir

func CountByConfigDir(sessions []Session, configDir, defaultDir string) int

CountByConfigDir counts sessions whose ConfigDir matches configDir. The empty/default account (acct-00) is matched by both an empty ConfigDir and one equal to defaultDir (~/.claude), since launching acct-00 via a mirror sets CLAUDE_CONFIG_DIR=~/.claude while plain `claude` leaves it unset.

Types

type Session

type Session struct {
	PID       int
	ConfigDir string // value of CLAUDE_CONFIG_DIR, or "" for the default dir
}

Session is a discovered live claude process.

func Scan

func Scan() ([]Session, error)

Scan returns all live claude sessions. claudeBaseNames are extra argv[0] basenames to treat as claude (besides "claude"); pass nil for the default.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL