From 1811ff4d339761384fbca84a444fcb8ffce22f1d Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Tue, 13 Oct 2026 12:50:55 +0100 Subject: [PATCH] Tests: find agents with pgrep, since macOS has no /proc --- tests/cli.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/cli.rs b/tests/cli.rs index 93b47a9..f4096a2 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -453,20 +453,12 @@ fn agent_rust_client_go_agent() { #[cfg(unix)] fn agent_pids(sock_dir: &Path) -> Vec { - let mut pids = Vec::new(); - for e in std::fs::read_dir("/proc").into_iter().flatten().flatten() { - let Ok(pid) = e.file_name().to_string_lossy().parse::() else { - continue; - }; - let Ok(cmd) = std::fs::read(e.path().join("cmdline")) else { - continue; - }; - let cmd = String::from_utf8_lossy(&cmd); - if cmd.contains("__agent") && cmd.contains(&*sock_dir.to_string_lossy()) { - pids.push(pid); - } - } - pids + // pgrep, not /proc: macOS has no /proc. + let o = Command::new("pgrep") + .args(["-f", &format!("__agent {}", sock_dir.display())]) + .output() + .unwrap(); + String::from_utf8_lossy(&o.stdout).lines().filter_map(|l| l.parse().ok()).collect() } #[cfg(target_os = "linux")]