Reliable process control without license toxicity.
sysprims provides GPL-free, cross-platform process utilities that can be statically or dynamically linked into your applications. When you need process control primitives but can't accept copyleft obligations, sysprims offers a straightforward solution.
Lifecycle Phase: alpha | See RELEASE_NOTES.md for current version
You're building software that needs to spawn processes with timeouts, send signals, or inspect running processes. Your options:
- Shell out to GNU coreutils — GPL licensed, can't statically link without license concerns
- Reimplement from scratch — Time-consuming, platform-specific edge cases everywhere
- Accept a Unix-only CLI — GNU
timeout9.11 and uutils already group-signal by default, but that does not give you Windows Job Objects, typed reliability receipts, or an embeddable license-clean library
- GPL-free: MIT/Apache-2.0 dual licensed. Link statically or dynamically without copyleft concerns.
- Group-by-default: Timeout acquires a dedicated group and targets every cooperative member through final escalation, with explicit reliability reporting.
- Cross-platform: Linux (musl + glibc), macOS (arm64), Windows (x64 + arm64) from a single API.
- Library-first: Embed directly in Rust, Go, Python, or TypeScript. CLIs are thin wrappers.
GNU coreutils 9.11 and uutils timeout already call setpgid and signal the
process group by default (--foreground opts out). sysprims is not a Unix
"GNU leaves orphans" replacement for that CLI behavior.
What sysprims adds:
- Windows Job Objects: prepared, exact-process assignment before first
execution, with typed boundary strength (
kernel_enforced_jobvs unknown) - Typed reliability receipts:
TreeKillReliability(includingbest_effortdegradation) in structured output so automation can detect it - Embeddable library: MIT/Apache-2.0, with Go, Python, and TypeScript bindings — not a GPL CLI you shell out to
Typical spawn without grouping:
Parent spawns Child
Child spawns Grandchildren
Parent times out, kills Child
Grandchildren continue running as orphans
→ CI jobs hang "after timing out"
→ Zombie processes in containers
→ Resource leaks in long-running services
sysprims behavior:
Parent spawns Child in new process group (Unix) / Job Object (Windows)
Child spawns cooperative Grandchildren (inherited group/job)
Parent times out, signals entire group/job
→ In-group processes are targeted together
→ Group cleanup is observable
On Unix, owned spawns use a setsid hook with a sealed same-spawn receipt and
signal through the retained guard with killpg. PID-only compatibility paths
cannot retain that proof and report best_effort. A process group is
cooperative containment: descendants can later leave it, so guaranteed
describes acquisition and group-signaling eligibility rather than OS-enforced
non-escape. Escape via setsid or double-fork is untested; this document does
not claim those descendants are reaped. On Windows, a prepared, exact-process
Job assignment before first execution can independently report
kernel_enforced_job; post-spawn adoption reports unknown boundary strength.
Job Objects use JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE without either breakaway
mode. Any degradation is exposed in structured output so automation can detect
it.
Platform Engineers: You need process utilities in your tooling but can't introduce GPL dependencies. sysprims gives you the primitives without the license overhead.
Library Authors: You're building something that spawns subprocesses and need reliable cleanup. Depend on sysprims instead of shelling out to timeout or reimplementing signal handling.
Enterprise Teams: Your legal department has opinions about copyleft licenses in your software supply chain. sysprims is designed for environments where license hygiene matters.
Large OSS Projects: You want to avoid license toxicity debates in your contributor community. MIT/Apache-2.0 is unambiguous.
The core release and its language packages share version 0.5.1, but each
ecosystem resolves that version through its own coordinate. Publication
workflows run from the verified core tag.
| Surface | Pin |
|---|---|
| Rust crates | sysprims-core, sysprims-evidence, sysprims-signal, sysprims-session, sysprims-proc, sysprims-timeout, and sysprims-recurrence at 0.5.1 |
| Rust workspace | Repository tag v0.5.1 |
Go module (pure Go, CGO_ENABLED=0) |
github.com/3leaps/sysprims/{syserror,signal,session,timeout,proc,evidence,procobserve}@v0.5.1 |
| Go recurrence module | github.com/3leaps/sysprims/go/recurrence@v0.5.1 |
| Python | pip install sysprims==0.5.1 |
| TypeScript | npm install @3leaps/sysprims@0.5.1 |
| PTY adapter | A separate sysprims-pty release; use the core revision recorded by that companion release |
The canonical v0.5.1 and path-prefixed go/recurrence/v0.5.1 tags identify the same
core commit. sysprims-pty has an independent version and tag lifecycle; it is
not included in the core tag. Only the seven Rust library crates are published
to crates.io; the CLI, TypeScript N-API crate, and Python PyO3
crate are release-built but not published as Rust crates.
Managed contained spawn is available in Go as SpawnContained, in Python as
spawn_contained, and in TypeScript as spawnContained.
[dependencies]
sysprims-timeout = "0.5.1"
sysprims-signal = "0.5.1"
sysprims-proc = "0.5.1"use sysprims_timeout::{
run_with_timeout, TimeoutConfig, TimeoutOutcome,
GroupingMode, TreeKillReliability, SIGTERM,
};
use std::time::Duration;
let config = TimeoutConfig {
signal: SIGTERM,
kill_after: Duration::from_secs(10),
grouping: GroupingMode::GroupByDefault,
preserve_status: false,
};
match run_with_timeout("./build.sh", &[], Duration::from_secs(30), config)? {
TimeoutOutcome::Completed { exit_status } => {
println!("Build finished with status: {:?}", exit_status);
}
TimeoutOutcome::TimedOut { signal_sent, escalated, tree_kill_reliability } => {
println!("Build timed out, sent signal {}, escalated: {}", signal_sent, escalated);
if tree_kill_reliability == TreeKillReliability::BestEffort {
eprintln!("Warning: tree kill may be incomplete");
}
}
}Stock macOS does not ship timeout. Use sysprims timeout 30s -- cmd,
uutils coreutils, or
brew install coreutils (gtimeout; the current formula may also expose
unprefixed timeout). BusyBox timeout is not GNU-parity. sysprims does not
install an unprefixed timeout on PATH. See
Installing a timeout CLI.
# Run command with 30 second timeout
sysprims timeout 30s -- ./long-build.sh
# Send signal to process
sysprims kill -s TERM 1234
# Run timeout with custom signal and escalation delay
sysprims timeout --signal TERM --kill-after 2s 5s -- ./long-build.sh
# List processes as JSON
sysprims pstat --json
# List processes with filters and table output
sysprims pstat --name nginx --cpu-above 5 --table
# Find actively high-CPU processes (Activity Monitor style)
sysprims pstat --cpu-mode monitor --sample "5s" --cpu-above 80 --table
# Inspect open file descriptors for a process
sysprims fds --pid 1234 --table
# Filter file descriptors by type
sysprims fds --pid 1234 --kind socket --json
# List listening ports
sysprims ports --table
# Filter by protocol and port
sysprims ports --protocol tcp --local-port 8080 --jsonThe default CPU measurement (--cpu-mode lifetime) takes an instantaneous snapshot, which may miss processes that spike between measurements. For finding actively consuming processes like Activity Monitor shows, use --cpu-mode monitor with sampling:
# Find processes actively using CPU (matches Activity Monitor behavior)
sysprims pstat --cpu-mode monitor --sample "5s" --cpu-above 80 --table
# Kill high-CPU descendants of a process (e.g., runaway IDE plugins)
sysprims kill-descendants 1234 --cpu-mode monitor --sample "3s" --cpu-above 90 --signal KILL --yes
# Find long-running processes that have accumulated high CPU time
sysprims pstat --cpu-above 50 --running-for "10m" --tableWhy monitor mode? Activity Monitor and top show sustained CPU usage averaged over time. The default lifetime mode measures CPU at a single instant, which can miss bursty processes between spikes. Use --cpu-mode monitor --sample "5s" to catch intermittent high-CPU processes.
# View process hierarchy with ASCII tree
sysprims descendants 7825 --tree
# Find high-CPU descendants of a parent
sysprims descendants 7825 --cpu-above 80 --tree
# Kill all descendants of a process (parent survives)
sysprims kill-descendants 7825 --yes
# Kill only high-CPU descendants (surgical cleanup)
sysprims kill-descendants 7825 --cpu-above 90 --signal KILL --yes
# Preview what would be killed (dry-run)
sysprims kill-descendants 7825 --cpu-above 80 --dry-run# 1. Find high-CPU processes
sysprims pstat --cpu-mode monitor --sample "5s" --cpu-above 50 --sort cpu --table
# 2. Inspect what files they have open
sysprims fds --pid <PID> --kind file --json
# 3. Check their process tree
sysprims descendants <PID> --tree
# 4. Terminate surgically (just the problematic descendants)
sysprims kill-descendants <PID> --cpu-above 80 --signal KILL --yes| Condition | Exit Code |
|---|---|
| Command completed (default) | 0 |
Command completed (with --preserve-status) |
Child's exit code |
| Command timed out | 124 |
| sysprims itself failed | 125 |
| Command not executable | 126 |
| Command not found | 127 |
| Killed by signal N | 128+N |
Process execution with deadlines and receipt-proven group signaling.
use sysprims_timeout::{run_with_timeout, run_with_timeout_default, TimeoutConfig, GroupingMode};
use std::time::Duration;
// Quick usage with defaults (SIGTERM, 10s escalation, group-by-default)
let result = run_with_timeout_default("make", &["build"], Duration::from_secs(300))?;
// Or configure explicitly
let config = TimeoutConfig {
grouping: GroupingMode::Foreground, // Opt out of owned group signaling
..Default::default()
};
let result = run_with_timeout("make", &["build"], Duration::from_secs(300), config)?;Cross-platform signal dispatch.
use sysprims_signal::{kill, kill_by_name, killpg, match_signal_names, terminate, force_kill, SIGTERM};
// Send specific signal (using rsfulmen constants)
kill(pid, SIGTERM)?;
// Platform-agnostic helpers
terminate(pid)?; // SIGTERM on Unix, TerminateProcess on Windows
force_kill(pid)?; // SIGKILL on Unix, TerminateProcess on Windows
// Resolve by name (accepts "SIGTERM", "TERM", "term")
kill_by_name(pid, "TERM")?;
// List available signals matching a glob pattern
let matches = match_signal_names("SIGT*");
// Process group operations (Unix only)
#[cfg(unix)]
killpg(pgid, SIGTERM)?;Signal mapping:
| Signal | Linux/macOS | Windows |
|---|---|---|
| TERM | SIGTERM | TerminateProcess |
| KILL | SIGKILL | TerminateProcess |
| INT | SIGINT | GenerateConsoleCtrlEvent (best-effort) |
| HUP, USR1, USR2 | Native | Not supported (returns error) |
Note: On Windows, SIGINT delivery is best-effort and depends on console
attachment and process group membership.
Process inspection, enumeration, and open file descriptor visibility.
use sysprims_proc::{
get_process_with_options, list_fds, snapshot, snapshot_filtered,
FdFilter, FdKind, ProcessFilter, ProcessOptions,
};
// Get all processes
let snap = snapshot()?;
for proc in &snap.processes {
println!("{}: {} ({}% CPU)", proc.pid, proc.name, proc.cpu_percent);
}
// Filter processes
let filter = ProcessFilter::builder()
.name_contains("nginx")
.cpu_above(10.0)
.build();
let filtered = snapshot_filtered(&filter)?;
// Get process with optional env + thread count (proc_ext, v0.1.14)
let info = get_process_with_options(
pid,
ProcessOptions::default().with_env().with_threads(),
)?;
println!("threads: {:?}", info.thread_count);
println!("NODE_ENV: {:?}", info.env.as_ref().and_then(|e| e.get("NODE_ENV")));
// Inspect open file descriptors (Linux/macOS)
let fd_filter = FdFilter { kind: Some(FdKind::File) };
let fds = list_fds(pid, Some(&fd_filter))?;
for fd in &fds.fds {
if let Some(path) = &fd.path {
println!("FD {}: {}", fd.fd, path);
}
}CLI:
# Process listing
sysprims pstat [OPTIONS]
sysprims pstat --json # JSON output (default)
sysprims pstat --table # Human-readable table
sysprims pstat --pid 1234 # Single process by PID
sysprims pstat --name nginx --cpu-above 10 # Filter by name and CPU
sysprims pstat --sort cpu # Sort by CPU usage
# Open file descriptor inspection
sysprims fds --pid 1234 # List all FDs
sysprims fds --pid 1234 --table # Human-readable table
sysprims fds --pid 1234 --kind file --json # Filter by typeFilter options:
| Option | Description |
|---|---|
--pid <PID> |
Show only a specific process |
--name <NAME> |
Filter by name (substring, case-insensitive) |
--user <USER> |
Filter by username |
--ppid <PID> |
Filter by parent PID |
--cpu-above <PERCENT> |
Filter by minimum CPU usage |
--cpu-mode <MODE> |
CPU measurement: lifetime (default, instant) or monitor (Activity Monitor style) |
--sample <DURATION> |
Sample CPU over interval (e.g., "5s") - use with monitor mode |
--memory-above <KB> |
Filter by minimum memory in KB |
--running-for <DURATION> |
Filter by minimum process age (e.g., "10m", "2h") |
--sort <FIELD> |
Sort by: pid, name, cpu, memory (default: pid) |
See Platform Support Matrix for the canonical reference.
| Platform | Target | Status |
|---|---|---|
| Linux x64 (glibc) | x86_64-unknown-linux-gnu |
Supported |
| Linux x64 (musl) | x86_64-unknown-linux-musl |
Supported |
| Linux arm64 (glibc) | aarch64-unknown-linux-gnu |
Supported |
| Linux arm64 (musl) | aarch64-unknown-linux-musl |
Supported |
| macOS arm64 | aarch64-apple-darwin |
Supported |
| Windows x64 | x86_64-pc-windows-msvc |
Supported |
| Windows arm64 | aarch64-pc-windows-msvc |
Supported |
Not supported: macOS x64 (Intel Macs) - end-of-life hardware.
Go packages (CGO_ENABLED=0): All Go packages under github.com/3leaps/sysprims (syserror, signal, session, timeout, proc, evidence, procobserve, and go/recurrence) are pure Go and require no C toolchain or prebuilt static libraries on any platform.
| Feature | Linux | macOS | Windows |
|---|---|---|---|
| Process tree kill | setpgid/killpg | setpgid/killpg | Job Objects |
| Signal TERM/KILL | Native | Native | Mapped |
| Signal INT | Native | Native | Best-effort |
| Signal HUP/USR1/2 | Native | Native | Not supported |
| Process enumeration | /proc | libproc | Toolhelp32 |
| Port enumeration | /proc/net/* | libproc (current user) | Not yet |
| Language | Implementation | Package |
|---|---|---|
| Go | Pure Go (CGO_ENABLED=0) |
github.com/3leaps/sysprims/{syserror,signal,session,timeout,proc,evidence,procobserve}@v0.5.1 |
| Python | Native PyO3 (cp310-abi3) |
pip install sysprims==0.5.1 |
| TypeScript | Native N-API (napi-rs) |
npm install @3leaps/sysprims@0.5.1 |
The Go implementation is pure Go (CGO_ENABLED=0) under module github.com/3leaps/sysprims:
import (
"time"
"github.com/3leaps/sysprims/proc"
"github.com/3leaps/sysprims/signal"
"github.com/3leaps/sysprims/timeout"
)
// Example target PID
pid := uint32(1234)
// Send signal to process
_ = signal.Kill(pid, signal.SIGTERM)
// Run command with timeout
result, err := timeout.RunWithTimeout(
"make", []string{"build"},
5*time.Minute,
timeout.DefaultTimeoutConfig(),
)
// Map listening port to owning process
proto := proc.ProtocolTCP
port := uint16(8080)
snap, _ := proc.ListeningPorts(&proc.PortFilter{
Protocol: &proto,
LocalPort: &port,
})
_ = snap
// Get process with opt-in fields (env + thread_count)
info, _ := proc.GetProcessWithOptions(pid, &proc.ProcessOptions{
IncludeEnv: true,
IncludeThreads: true,
})
_ = info
_ = result
_ = err
// Find and kill actively hot descendants (monitor sampling)
cpu := 90.0
killResult, _ := proc.KillDescendantsWithOptions(pid, &proc.KillDescendantsOptions{
Signal: signal.SIGKILL,
CpuMode: proc.CpuModeMonitor,
SampleDuration: 3 * time.Second,
Filter: &proc.ProcessFilter{
CPUAbove: &cpu,
},
})
_ = killResultFor a migration-focused walkthrough, see docs/guides/replace-shell-outs-go.md.
import {
processList,
listeningPorts,
terminate,
procGet,
} from "@3leaps/sysprims";
// Get process info by PID (with optional env + thread count, v0.1.14)
const proc = procGet(process.pid, { includeEnv: true, includeThreads: true });
console.log(`Process ${proc.pid}: ${proc.name}`);
console.log(`NODE_ENV: ${proc.env?.NODE_ENV}`);
// List processes matching a filter
const nginx = processList({ name_contains: "nginx" });
// Map listening port to owning process
const http = listeningPorts({ local_port: 8080 });
// Gracefully terminate a process
terminate(pid);Note: TypeScript bindings support Linux (glibc and musl/Alpine), macOS (arm64), and Windows (x64 and arm64).
See docs/guides/language-bindings.md for build requirements and platform details.
sysprims integrates with the Fulmen ecosystem:
- rsfulmen: sysprims uses rsfulmen's signal constants (
SIGTERM,SIGKILL, etc.) for cross-platform consistency - sysprims-pty: separately versioned PTY adapter for prepared Unix session acquisition and create-suspended Windows Job containment
- Go bindings: Available with consistent signal semantics
- Python bindings: Available through the
cp310-abi3sysprimspackage on PyPI - TypeScript bindings: Available through the Node-API package above
This ensures signal semantics and exit codes are consistent whether you're writing Rust, Go, Python, or TypeScript.
sysprims builds on the work of others in this space:
- uutils/coreutils — MIT-licensed Rust rewrite of GNU coreutils. Excellent CLI tools, though focused on POSIX compatibility rather than embeddable library use.
- subprocess — Process spawning library. Great for basic spawning, though without timeout/tree-kill semantics.
We're not claiming to replace these projects. sysprims fills a specific niche: embeddable, license-clean process primitives with first-class bindings and group-by-default behavior.
# Build
cargo build
# Test
cargo test
# Full quality check
make checkcargo fmt --check— zero diffcargo clippy -- -Dwarnings— zero warningscargo test— all tests passcargo deny check— no GPL dependencies
sysprims is designed for environments where dependency hygiene matters:
- License-clean: All dependencies use MIT, Apache-2.0, or compatible licenses
- Auditable: Run
cargo treeto inspect the full dependency graph - SBOM-ready: Compatible with
cargo sbom - No runtime network calls: All functionality is local
# Check dependencies
cargo deny check licenses
# Audit for vulnerabilities
cargo audit
# Generate SBOM
cargo sbom > sbom.jsonLicensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option. See NOTICE for project name and trademark terms.
Apache-2.0 provides explicit patent grants, which may be valuable for enterprise adoption.
See CONTRIBUTING.md for guidelines and MAINTAINERS.md for governance.
Built by the 3 Leaps team
Part of the Fulmen Ecosystem