Documentation
¶
Overview ¶
Package fgproc names the program a shell is running in its foreground: what a terminal app asks before it closes a tab ("Shell 1 is running claude").
On macOS and Linux the answer is the terminal's foreground process group, read from the shell process itself (its tpgid): when that group is not the shell's own, a job is in front of the prompt, and the group's leader names it. Nothing here opens the terminal or talks to the pty-host; the kernel keeps the tpgid on every process of the session. On Windows it is a scan for the shell's child processes, best effort: it may name nothing, and it never fails.
The name is the program's argv[0] as typed, not the kernel's short name: Claude Code's native binary is a file named after its version, so the kernel calls it "2.1.289" while argv[0] says "claude".
Callers pass only the pid of a shell Caprock started (rule 7); this package reads, it never signals.
Index ¶
Constants ¶
const Unnamed = "program"
Unnamed is what Foreground answers for a job it can see but not name, such as a pipeline whose first process has already exited.
Variables ¶
This section is empty.
Functions ¶
func Foreground ¶
Foreground is the name of the program in front of the shell with this pid, or "" when the shell is at its prompt, has exited, or the platform cannot tell.
func InJob ¶ added in v0.185.2
InJob reports whether the process pid belongs to job, as Job returned it: its process group is the job's (macOS, Linux), or the job is the process or one of its parents (Windows). False when either is unknown or gone.
func Job ¶ added in v0.185.2
Job is Foreground with the job it names: on macOS and Linux the terminal's foreground process group, on Windows the shell's child process; 0 with the name "". InJob answers whether a process belongs to it — how the daemon tells that the job in front of a shell's prompt is a session it observes ("claude --resume …" typed into a shell tab, owner, 2026-11-20).
Types ¶
This section is empty.