proc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 7 Imported by: 0

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.

func IsAlive

func IsAlive(pid int) bool

IsAlive returns true if the process with the given PID is still running.

Types

This section is empty.

Jump to

Keyboard shortcuts

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