Documentation
¶
Overview ¶
Package proc provides process tree utilities for identifying long-lived ancestor processes (e.g., the agent binary that launched a hook subprocess chain).
Problem: hooks run as: agent (e.g., claude) → bash → ox agent hook → ox agent prime. os.Getppid() in any hook subprocess returns the transient bash PID, which dies immediately. FindAgentAncestorPID walks the tree to find the actual agent process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAgentAncestorPID ¶
func FindAgentAncestorPID() int
FindAgentAncestorPID walks the process tree from the current process's parent upward, looking for the first ancestor whose name matches a known agent binary.
This is necessary because hooks run inside a transient bash shell spawned by the agent, so os.Getppid() returns the bash PID (which dies), not the agent PID.
If AGENT_ENV is set in the environment, its resolved binary name is searched first so we find the correct agent quickly without scanning all known names.
Returns the matching ancestor PID, or os.Getppid() as fallback if no agent found.
Types ¶
This section is empty.