From ac710cc2502efbcdee688c0838b4edaea06c1d66 Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 22:58:02 +0200 Subject: [PATCH 1/7] Replace darwin-libproc dependency --- Cargo.toml | 3 +-- src/macos.rs | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ebbb07..ed9106b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,5 +23,4 @@ procfs = "0.18" libc = "0.2" [target.'cfg(target_os = "macos")'.dependencies] -darwin-libproc = "0.2" -libc = "0.2" +libproc = "0.14" diff --git a/src/macos.rs b/src/macos.rs index a70de56..90b9499 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -1,9 +1,10 @@ use crate::{Error, ProcessStats}; use std::time::Duration; +use libproc::proc_pid::pidinfo; pub fn get_info() -> Result { - let pid = unsafe { libc::getpid() }; - let proc_info = darwin_libproc::task_info(pid).map_err(Error::SystemCall)?; + let pid = std::process::id() as i32; + let proc_info = pidinfo::(pid, 0).map_err(Error::SystemCall)?; let timebase_info = mach_timebase_info::get(); Ok(ProcessStats { From 517ff5d7c316892f8ed18e34f5cbfea4161832f4 Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 22:58:55 +0200 Subject: [PATCH 2/7] cargo fmt --- src/macos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macos.rs b/src/macos.rs index 90b9499..5dc0ee1 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -1,6 +1,6 @@ use crate::{Error, ProcessStats}; -use std::time::Duration; use libproc::proc_pid::pidinfo; +use std::time::Duration; pub fn get_info() -> Result { let pid = std::process::id() as i32; From 024af4bb6a3fddb344bac56631e207bbc6415d7c Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 23:00:40 +0200 Subject: [PATCH 3/7] add import --- src/macos.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/macos.rs b/src/macos.rs index 5dc0ee1..f22d70e 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -1,5 +1,6 @@ use crate::{Error, ProcessStats}; use libproc::proc_pid::pidinfo; +use libproc::task_info::TaskInfo; use std::time::Duration; pub fn get_info() -> Result { From 606b5c78e958e26178040805cf5c5657f3e306c0 Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 23:06:04 +0200 Subject: [PATCH 4/7] add libc back --- Cargo.toml | 1 + src/macos.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed9106b..fb3cee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,4 @@ libc = "0.2" [target.'cfg(target_os = "macos")'.dependencies] libproc = "0.14" +libc = "0.2" diff --git a/src/macos.rs b/src/macos.rs index f22d70e..317c38a 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -4,8 +4,8 @@ use libproc::task_info::TaskInfo; use std::time::Duration; pub fn get_info() -> Result { - let pid = std::process::id() as i32; - let proc_info = pidinfo::(pid, 0).map_err(Error::SystemCall)?; + let pid = unsafe { libc::getpid() }; + let proc_info = pidinfo::(pid as i32, 0).map_err(Error::SystemCall)?; let timebase_info = mach_timebase_info::get(); Ok(ProcessStats { From 4b2c2a1aa39a9f05bbda7f8abd4195e4abf800ae Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 23:13:31 +0200 Subject: [PATCH 5/7] maybe fix error mapping --- src/lib.rs | 2 +- src/macos.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 21272a3..2347626 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,6 +79,6 @@ pub enum Error { FileContentsMalformed, /// A system-native function returned an error code. - #[error("Call to system-native API errored: {0}")] + #[error("Call to system-native API failed: {0}")] SystemCall(std::io::Error), } diff --git a/src/macos.rs b/src/macos.rs index 317c38a..dba3ce7 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -5,7 +5,7 @@ use std::time::Duration; pub fn get_info() -> Result { let pid = unsafe { libc::getpid() }; - let proc_info = pidinfo::(pid as i32, 0).map_err(Error::SystemCall)?; + let proc_info = pidinfo::(pid as i32, 0).map_err(std::io::Error::other).map_err(Error::SystemCall)?; let timebase_info = mach_timebase_info::get(); Ok(ProcessStats { From f2b9ca3c0ee455073c514ef783b4b96a89b75088 Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 23:14:26 +0200 Subject: [PATCH 6/7] cargo fmt --- src/macos.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/macos.rs b/src/macos.rs index dba3ce7..deb9bc1 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -5,7 +5,9 @@ use std::time::Duration; pub fn get_info() -> Result { let pid = unsafe { libc::getpid() }; - let proc_info = pidinfo::(pid as i32, 0).map_err(std::io::Error::other).map_err(Error::SystemCall)?; + let proc_info = pidinfo::(pid as i32, 0) + .map_err(std::io::Error::other) + .map_err(Error::SystemCall)?; let timebase_info = mach_timebase_info::get(); Ok(ProcessStats { From 4ba0c9551bff6bc8049c19b7392342c2fc13f957 Mon Sep 17 00:00:00 2001 From: Ruben Anders Date: Mon, 13 Jul 2026 23:16:45 +0200 Subject: [PATCH 7/7] show test output --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 32291fc..28b3d0b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@stable - name: Run tests - run: cargo test + run: cargo test --verbose -- --nocapture build: runs-on: ${{ matrix.os }} strategy: