Documentation
¶
Overview ¶
Package proc finds Claude's process from a hook or the statusline: its pid, its start time with the boot it belongs to, and whether another session started it (design-spec.md, Liveness; implementation-spec.md, Process lookup). The rules are one implementation over a process table (procTable); only the table differs by system: /proc through fsys on Linux (procfs), sysctl through golang.org/x/sys/unix on macOS (sysctlTable). Both tables' parsing builds everywhere, so it is tested on any system. It never starts a process. On other systems it finds nothing.
sesshin-hook links it, so it imports the standard library, sesshin's own hook-path packages, and golang.org/x/sys/unix only, starts no goroutine, and has no init function or package-level initializer that does work (implementation-spec.md, The hook binary).
Index ¶
Constants ¶
const ( // ErrNoProcess is StartedAt's error when there is no such process. ErrNoProcess constError = "no such process" // ErrNoTTY is ControllingTTY's error when the process has no controlling // terminal. ErrNoTTY constError = "no controlling terminal" )
Variables ¶
This section is empty.
Functions ¶
func ControllingTTY ¶ added in v1.1.0
ControllingTTY finds nothing on Linux, where no backend asks.
Types ¶
type Claude ¶
type Claude struct {
PID int64
// StartedAt is pid_started_at: linux:<boot_id>:<starttime> or
// darwin:<boot session>:<sec>.<usec>, compared only for equality.
StartedAt string
// Nested is whether another session started this Claude, nil when that
// couldn't be told.
Nested *bool
}
Claude is what a lookup found. PID is 0 when it found no Claude, and then StartedAt is "" and Nested nil: pid_started_at is null exactly when pid is (design-spec.md, lifecycle.json).
func Find ¶
Find looks up Claude from this process, a hook or the statusline that Claude started, given CLAUDE_PID from its environment ("" when unset). It reads only the process table, and takes no lock.
func FindCaller ¶
FindCaller looks up the Claude this process, a command, runs under, given CLAUDE_PID from its environment ("" when unset), for the selector self: the nearest ancestor that is CLAUDE_PID or a claude by name.