process

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package process discovers and inspects running processes. A snapshot carries process identity (pid, start identity, parent), the executable and owner, and, on request, bounded file, mapping, socket and IPC evidence and usage. Coverage says whether an empty answer means nothing was there or the OS did not allow looking. Arguments, environment contents and file contents are never collected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstanceID

func InstanceID(host string, p ProcessInfo) string

InstanceID returns the identifier of one process instance on a host. The host, pid and start identity together make it up, so a reused pid is a different instance.

Types

type ApplicationInfo

type ApplicationInfo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

ApplicationInfo identifies an application through OS packaging conventions. It does not assign product capabilities or infer an engine from a name.

type CollectionStatus

type CollectionStatus struct {
	State string `json:"state"`
	// Reason says why something is missing, from the set every package shares
	// (testdata/capability/v1): unsupported, permission, no_device or tool_missing.
	Reason     string     `json:"reason,omitempty"`
	Detail     string     `json:"detail,omitempty"`
	ObservedAt *time.Time `json:"observed_at,omitempty"`
}

CollectionStatus distinguishes an empty observation from inaccessible data. State is complete, partial, permission-denied, unsupported, exited, or unavailable. Detail is a diagnostic, never process arguments or environment contents.

func (CollectionStatus) Validate added in v0.4.0

func (s CollectionStatus) Validate() error

Validate checks that the state is known and the reason fits it (see the capability fixtures).

type ProcessInfo

type ProcessInfo struct {
	PID         int                         `json:"pid"`
	ParentPID   int                         `json:"parent_pid"`
	Name        string                      `json:"name"`
	StartID     string                      `json:"start_id,omitempty"`
	Executable  string                      `json:"executable,omitempty"`
	Owner       string                      `json:"owner,omitempty"`
	Application *ApplicationInfo            `json:"application,omitempty"`
	Usage       *ProcessUsage               `json:"usage,omitempty"`
	Coverage    map[string]CollectionStatus `json:"coverage"`
	Resources   []ProcessResource           `json:"resources,omitempty"`
	// contains filtered or unexported fields
}

ProcessInfo identifies a process instance using PID and an OS start identity. StartID is opaque and platform-specific. Empty StartID means identity could not be established; such entries are returned but never projected as stable nodes.

func Lookup

func Lookup(ctx context.Context, pid int) (ProcessInfo, error)

Lookup returns the native record for one process, without resource detail. It is the lightweight form of InspectProcess for callers that only need to identify the process behind a window or accessibility element.

type ProcessOptions

type ProcessOptions struct {
	MaxProcesses int
	MaxResources int
	Timeout      time.Duration
}

ProcessOptions bounds returned records and collection time. Zero values select 4096 processes, 1024 resources per category, and a ten-second deadline. Detailed resource inspection is opt-in through InspectProcess.

type ProcessResource

type ProcessResource struct {
	Kind          string `json:"kind"`
	Path          string `json:"path,omitempty"`
	Descriptor    string `json:"descriptor,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
	LocalAddress  string `json:"local_address,omitempty"`
	RemoteAddress string `json:"remote_address,omitempty"`
	Endpoint      string `json:"endpoint,omitempty"`
	State         string `json:"state,omitempty"`
}

ProcessResource is OS evidence. A socket does not imply an automation API. Endpoint preserves an OS-rendered address when its roles cannot be established. Descriptors are process-local observations, not reusable handles.

type ProcessSnapshot

type ProcessSnapshot struct {
	HostID      string           `json:"host_id"`
	Scope       string           `json:"scope"`
	ObservedAt  time.Time        `json:"observed_at"`
	Enumeration CollectionStatus `json:"enumeration"`
	Processes   []ProcessInfo    `json:"processes"`
}

ProcessSnapshot is a non-atomic, point-in-time OS observation. Scope is all or process; only complete all-process enumeration permits removing absent PIDs. HostID includes the boot/namespace identity so records cannot cross reboots.

func DiscoverProcesses

func DiscoverProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)

DiscoverProcesses collects identities without scanning every process's files. Processes hidden by the OS are outside this caller-visible inventory.

func InspectProcess

func InspectProcess(ctx context.Context, pid int, options ProcessOptions) (ProcessSnapshot, error)

InspectProcess inspects one process and checks its identity again afterwards. Resources collected during exit or PID reuse are discarded, never reassigned.

type ProcessUsage

type ProcessUsage struct {
	ResidentBytes *uint64  `json:"resident_bytes,omitempty"`
	VirtualBytes  *uint64  `json:"virtual_bytes,omitempty"`
	CPUSeconds    *float64 `json:"cpu_seconds,omitempty"`
	Threads       *uint32  `json:"threads,omitempty"`
}

Jump to

Keyboard shortcuts

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