Documentation
¶
Overview ¶
Package process provides low level operations on OS processes
Index ¶
Constants ¶
const ToolHiveDetachedEnv = "TOOLHIVE_DETACHED"
ToolHiveDetachedEnv is the environment variable used to indicate that the process is running in detached mode.
const ToolHiveDetachedValue = "1"
ToolHiveDetachedValue is the expected value of ToolHiveDetachedEnv when set.
Variables ¶
This section is empty.
Functions ¶
func FindProcess ¶
FindProcess finds a process by its ID and checks if it's running. This function works on Unix systems (Linux and macOS).
func IsDetached ¶ added in v0.0.33
func IsDetached() bool
IsDetached checks if the process is running in detached mode.
func IsToolHiveProxyForWorkload ¶ added in v0.11.1
IsToolHiveProxyForWorkload returns true if the given PID belongs to the ToolHive proxy for the specified workload, so it is safe to kill when freeing a port. Returns false if the process is not that workload's proxy or if identity cannot be verified (fail-safe: do not kill).
When workloadName is empty, only verifies it is a ToolHive process. When workloadName is non-empty, also verifies the process cmdline contains " start <workloadName> " (the detached proxy runs "thv start <name> --foreground").
Verification checks, in order:
- TOOLHIVE_DETACHED=1 in process environment (most reliable)
- "thv" in executable path or command line (fallback when env unavailable)
- workloadName in cmdline (when provided, avoids killing another workload's proxy)
func WaitForExit ¶ added in v0.11.1
WaitForExit waits for the process with the given PID to exit. It polls FindProcess every 50ms until the process is no longer running or the context is cancelled. Callers should use context.WithTimeout to impose a deadline. Returns nil when the process has exited, or an error on context cancellation.
Types ¶
This section is empty.