procutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package procutil provides shared process helpers for AGH runtime components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alive

func Alive(pid int) bool

Alive reports whether a process with the given PID is running.

func ConfigureCommandProcessGroup

func ConfigureCommandProcessGroup(cmd *exec.Cmd)

ConfigureCommandProcessGroup starts the command in its own process group so callers can signal and observe the full descendant tree.

func FilteredDaemonEnv

func FilteredDaemonEnv(base []string) []string

FilteredDaemonEnv returns process environment entries safe to pass to child processes.

func IsolatedDaemonEnv

func IsolatedDaemonEnv(base []string) []string

IsolatedDaemonEnv returns only the fixed operational environment allowlist needed to launch local subprocesses. It intentionally drops all non-allowlisted daemon variables, including provider CLI credentials.

func KillCommandProcessGroupAndWait

func KillCommandProcessGroupAndWait(cmd *exec.Cmd, timeout time.Duration) error

KillCommandProcessGroupAndWait forcefully terminates any remaining members of the command's process group, then waits for the group to disappear.

func KillProcessGroupIDAndWait

func KillProcessGroupIDAndWait(pgid int, timeout time.Duration) error

KillProcessGroupIDAndWait forcefully terminates any remaining members of a process group.

func MatchesStartTime

func MatchesStartTime(pid int, startedAt time.Time) bool

MatchesStartTime reports whether pid currently belongs to a process whose observed start time matches the recorded value closely enough to account for launcher-vs-kernel timestamp skew.

func RegisterCommandProcessGroup

func RegisterCommandProcessGroup(_ *exec.Cmd) error

RegisterCommandProcessGroup keeps Unix parity with Windows job registration.

func SensitiveEnvName

func SensitiveEnvName(name string) bool

SensitiveEnvName reports whether an environment variable name commonly carries credentials.

func Signal

func Signal(pid int, sig syscall.Signal) error

Signal sends sig to the process with the given PID.

func SignalCommandProcessGroup

func SignalCommandProcessGroup(cmd *exec.Cmd, sig syscall.Signal) error

SignalCommandProcessGroup delivers sig to the command's process group.

func SignalProcessGroupID

func SignalProcessGroupID(pgid int, sig syscall.Signal) error

SignalProcessGroupID delivers sig to the process group identified by pgid.

func StartedAt

func StartedAt(pid int) (time.Time, error)

StartedAt reports the observed start time for pid using the host process table.

func WaitForCommandProcessGroupExit

func WaitForCommandProcessGroupExit(cmd *exec.Cmd, timeout time.Duration) error

WaitForCommandProcessGroupExit blocks until the command's process group no longer exists, which ensures descendants are gone before returning.

func WaitForProcessGroupIDExit

func WaitForProcessGroupIDExit(pgid int, timeout time.Duration) error

WaitForProcessGroupIDExit blocks until the process group identified by pgid no longer exists.

Types

type DetachedLaunchRequest

type DetachedLaunchRequest struct {
	Binary  string
	Args    []string
	Sandbox []string
	LogPath string
}

DetachedLaunchRequest describes one detached process launch with log capture.

type DetachedProcess

type DetachedProcess struct {
	// contains filtered or unexported fields
}

DetachedProcess wraps a detached child process whose stderr/stdout were appended to a log file.

func SpawnDetachedLoggedProcess

func SpawnDetachedLoggedProcess(
	ctx context.Context,
	req DetachedLaunchRequest,
) (*DetachedProcess, error)

SpawnDetachedLoggedProcess launches one detached child process whose stdout/stderr are appended to req.LogPath.

func (*DetachedProcess) Done

func (p *DetachedProcess) Done() <-chan struct{}

Done closes after the detached child has been reaped.

func (*DetachedProcess) PID

func (p *DetachedProcess) PID() int

PID reports the launched process id.

func (*DetachedProcess) Wait

func (p *DetachedProcess) Wait() error

Wait blocks until the detached process exits and attaches recent log output to failures.

Jump to

Keyboard shortcuts

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