Usage Examples
This section provides practical examples for common use cases of smearor-wrot-process-manager.
Examples
- Simple Child Process - Spawn a process with piped output capture via tracing
- Forked / Detached Process - Spawn a daemon that detaches from the controlling terminal via
setsid() - Reaper Monitoring - Detect process exits with
ProcessExitEvent, implement restart logic, and integrate with GTK - Label-based Grouping - Manage multiple processes under a shared label for grouped start/stop
- Stop Escalation - Observe SIGTERM to SIGKILL escalation with a short timeout
- Restart - Restart a process preserving its config and label
- Wayland Socket Binding - Bind a child process to a Wayland socket by setting
WAYLAND_DISPLAY - Send Signal - Send arbitrary signals (SIGHUP, SIGUSR1, etc.) to running processes
Common Patterns
All examples share these common patterns:
- Create a
ProcessManager- Eithernew()(no reaper) orwith_reaper()(with exit notifications) - Build a
ProcessConfig- Using theTypedBuilderpattern with.command()as the only required field - Start the process -
manager.start(label, &config)returns aProcessId - Stop or monitor - Call
manager.stop(id)for explicit termination, or use the reaper for exit detection