tinyhumansai/openhuman · warning
proc_metrics::sample_tree supports Linux and macOS (this is
Error message
proc_metrics::sample_tree supports Linux and macOS (this is a {} build) What it means
proc_metrics::sample_tree samples the process plus its children (children via /proc on Linux and proc_listchildpids on macOS, skipping children whose rusage call fails) and assembles a TreeSample; every platform other than Linux and macOS compiles a stub that bails with the build's OS name instead of fabricating readings. Same intentional-honesty design as sample_self, one level up the process tree.
Source
Thrown at src/openhuman/platform/proc_metrics/tree.rs:202
pid,
name: macos::proc_name(pid),
rss_kib,
}),
None => {
eprintln!(
"[proc_metrics] tree: skipping child pid={pid}: proc_pid_rusage unavailable (exited or permission denied)"
);
}
}
}
Ok(TreeSample::assemble(self_sample, children))
}
/// Unsupported-platform stub — fails loudly rather than fabricating a reading.
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
pub fn sample_tree() -> anyhow::Result<TreeSample> {
anyhow::bail!(
"proc_metrics::sample_tree supports Linux and macOS (this is a {} build)",
std::env::consts::OS
)
}
#[cfg(target_os = "macos")]
mod macos {
use std::collections::HashSet;
use std::mem::{size_of, MaybeUninit};
/// Direct children of `ppid` via `proc_listchildpids`. Empty on any error.
///
/// Note the Darwin ABI quirk: `proc_listchildpids` returns the **number of
/// pids** written (not a byte count, unlike `proc_listpids`), and fills the
/// buffer with that many `pid_t`. It also doesn't reliably support the NULL
/// size-probe form, so we allocate a real buffer up front and grow it if the
/// kernel filled it completely (the list may have been truncated).
fn child_pids(ppid: i32) -> Vec<i32> {View on GitHub (pinned to 7491200858)
Solutions
- Gate the caller: skip tree metrics on unsupported platforms.
- Contribute a Windows implementation of the child-enumeration path upstream if needed.
- Design dashboards to tolerate an absent tree sample rather than erroring.
Example fix
// before
let tree = proc_metrics::sample_tree()?;
// after — degrade to "no tree sample" on unsupported platforms
let tree = match proc_metrics::sample_tree() {
Ok(t) => Some(t),
Err(e) if e.to_string().contains("supports Linux and macOS") => None,
Err(e) => return Err(e),
}; Defensive patterns
Strategy: fallback
Validate before calling
fn proc_metrics_supported() -> bool {
matches!(std::env::consts::OS, "linux" | "macos")
}
if proc_metrics_supported() {
let tree = proc_metrics::sample_tree()?;
// ...
} Type guard
fn can_sample_tree() -> bool {
matches!(std::env::consts::OS, "linux" | "macos")
} Try / catch
Match the 'supports Linux and macOS' message and degrade to a self-only or absent tree sample; distinguish it from per-child skip warnings (proc_pid_rusage unavailable), which the Linux/macOS path already tolerates.
Prevention
- cfg-gate tree-metric wiring per target.
- Design health panels to render without child-process data.
- Contribute platform implementations rather than stubbing silently.
When it happens
Trigger: Calling proc_metrics::sample_tree() in a windows (or otherwise non-linux/macos) build — e.g. a health monitor that includes child-process CPU/memory on the Windows desktop target.
Common situations: Windows desktop builds with tree-aware health panels; cross-platform test matrices; ports to BSD/Android.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- proc_metrics::sample_self supports Linux and macOS (this is
- Service management is supported on macOS, Linux, and Windows
AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17).
Data as JSON: /api/errors/872e0913d8922b39.
Report an issue: GitHub.