Skip to main content

Crate sysprims_proc

Crate sysprims_proc 

Source
Expand description

sysprims-proc: Process inspection and enumeration utilities

This crate provides cross-platform process inspection capabilities with a stable JSON schema for automation. It supports listing all processes, filtering by various criteria, and getting details for a specific PID.

§Features

  • Process enumeration: List all running processes
  • Process inspection: Get details for a single process by PID
  • Filtering: Filter by name, state, CPU, memory, user
  • Stable JSON output: Schema-versioned output for automation

§Platform Support

FeatureLinuxmacOSWindows
PID enumeration/procproc_listpidsToolhelp32
Process info/proc/[pid]/*proc_pidinfoOpenProcess
CPU usage/proc/[pid]/statproc_pidinfoGetProcessTimes
Memory usage/proc/[pid]/statmproc_pidinfoGetProcessMemoryInfo

§Examples

use sysprims_proc::{snapshot, get_process, ProcessFilter};

// Get all processes
let snap = snapshot().unwrap();
println!("Found {} processes", snap.processes.len());

// Get current process
let self_info = get_process(std::process::id()).unwrap();
println!("Current process: {} (PID {})", self_info.name, self_info.pid);

// Filter processes by name
let filter = ProcessFilter {
    name_contains: Some("rust".into()),
    ..Default::default()
};
let filtered = sysprims_proc::snapshot_filtered(&filter).unwrap();

Modules§

observation
Read-only native-process-observation:v0 OS collectors and continuity handles. Read-only OS collectors and private continuity handles for urn:3leaps:identity-evidence:native-process-observation:v0.

Structs§

AncestorsResult
Result of an ancestors traversal.
DescendantsConfig
Configuration for descendants traversal.
DescendantsLevel
A single level in a descendants result.
DescendantsResult
Result of a descendants traversal.
FdFilter
Filter for fd queries.
FdInfo
Information about a single file descriptor.
FdSnapshot
Snapshot of open file descriptors for a process.
GuardConfig
Configuration for one guard evaluation cycle.
GuardEvent
Structured output for one guard evaluation cycle.
GuardRule
Rule configuration for one guard evaluation cycle.
GuardRunner
Managed guard loop with signal handling and drift-free scheduling.
GuardRunnerConfig
Configuration for a managed guard loop.
GuardRunnerSummary
Summary returned after a guard loop completes.
GuardStopHandle
Cloneable, thread-safe handle for stopping a running guard loop.
PortBinding
Listening socket binding information.
PortBindingsSnapshot
Snapshot of listening ports at a point in time.
PortFilter
Filter for port queries.
ProcessFilter
Filter for process queries.
ProcessHandle
Re-exported process-bound signal and exit-watch handle (ProcessHandle) from sysprims-signal. A signal and exit-watch handle bound to a verified process incarnation.
ProcessInfo
Information about a single process.
ProcessOptions
Options controlling optional process detail collection.
ProcessSnapshot
Snapshot of all processes at a point in time.
WaitPidResult
Result of waiting for a PID to exit.

Enums§

CpuMode
CPU measurement mode for descendants traversal.
FdKind
File descriptor kind.
GuardAction
Action configuration for one guard evaluation cycle.
GuardPreset
Preset configurations for common guard use cases.
ProcessState
Process state.
Protocol
Protocol for a socket binding.
SignalBinding
Re-exported process-bound signal and exit-watch handle (ProcessHandle) from sysprims-signal. How tightly signal delivery on a ProcessHandle is bound to the target process incarnation.
StopReason
Why the guard loop stopped.

Functions§

ancestors
Walk the parent chain from pid upward, collecting process info at each step.
cpu_total_time_ns
Get total CPU time consumed by a process (kernel + user) in nanoseconds.
descendants
Get descendants of a process using BFS traversal.
descendants_with_config
Get descendants using explicit traversal configuration.
descendants_with_config_and_options
Get descendants using explicit traversal configuration and optional extended fields.
descendants_with_options
Get descendants of a process using BFS traversal with optional extended fields.
get_process
Get information for a single process.
get_process_with_options
Get information for a single process with optional extended fields.
guard_step
Execute one guard evaluation cycle.
is_fully_gone
Report whether a PID has no observable process record (fully gone).
is_live
Report whether a PID refers to a live (non-zombie) process.
list_fds
List open file descriptors for a PID.
listening_ports
Get a snapshot of listening ports.
open_process_handle
Re-exported process-bound signal and exit-watch handle (ProcessHandle) from sysprims-signal. Open a ProcessHandle bound to the current live process incarnation at pid.
open_process_handle_verified
Re-exported process-bound signal and exit-watch handle (ProcessHandle) from sysprims-signal. Open a ProcessHandle bound to pid, requiring its native start-identity to match expected_start_identity.
process_by_port
Resolve a process by port and protocol.
select_descendant_targets
Select descendant target PIDs from a traversal result.
snapshot
Get a snapshot of all processes.
snapshot_filtered
Get a snapshot with filter applied.
snapshot_filtered_with_options
Get a snapshot with filter applied and optional extended fields.
snapshot_with_options
Get a snapshot of all processes with optional extended fields.
wait_pid
Wait for a PID to exit, up to the provided timeout.