Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ procfs = "0.18"
libc = "0.2"

[target.'cfg(target_os = "macos")'.dependencies]
darwin-libproc = "0.2"
libproc = "0.14"
libc = "0.2"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
6 changes: 5 additions & 1 deletion src/macos.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use crate::{Error, ProcessStats};
use libproc::proc_pid::pidinfo;
use libproc::task_info::TaskInfo;
use std::time::Duration;

pub fn get_info() -> Result<ProcessStats, Error> {
let pid = unsafe { libc::getpid() };
let proc_info = darwin_libproc::task_info(pid).map_err(Error::SystemCall)?;
let proc_info = pidinfo::<TaskInfo>(pid as i32, 0)
.map_err(std::io::Error::other)
.map_err(Error::SystemCall)?;
let timebase_info = mach_timebase_info::get();

Ok(ProcessStats {
Expand Down
Loading