processkit
Child-process management for Rust. A port of the .NET ProcessKit library, providing two layers:
- Process groups (
ProcessGroup) — spawn a child as the root of a process tree that is killed as a unit when the group is dropped, using Windows Job Objects and Linux cgroup v2 (with a POSIX process-group fallback), so no descendant ever outlives its owner. - Process runner (
Command) — async (tokio) run-and-capture of a child'sstdout/stderrand exit status, built on the group layer, with a mockableProcessRunnerseam for tests.
Async throughout. Errors are structured (Error); a non-zero exit is reported in
the result, not raised, until you call ProcessResult::ensure_success.
Status: at parity with the .NET library — process groups, the runner and capture helpers, streaming, interactive stdin, push line-handlers, output-buffer policies, encoding overrides, line counters, and CPU/memory stats. See
CHANGELOG.md.
Install
This crate requires a tokio runtime.
Usage
use ;
async
Wrapping a CLI tool
CliClient + the cli_client! macro turn a typed wrapper around an external
tool (git, jj, gh, …) into just its parsers — the runner is injectable, so
the wrapper is hermetically testable with a ScriptedRunner (no subprocess):
use ;
use Path;
cli_client!
Testing
License
Licensed under the MIT License.