Skip to content

Commit 86c657b

Browse files
Merge pull request #41 from andrewdavidmackenzie/pidpath
pidpath - with some extra edits
2 parents a74236a + e5c8517 commit 86c657b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn pidinfo<T: PIDInfo>(pid : i32, arg: u64) -> Result<T, String> (macos)
3636
pub fn regionfilename(pid: i32, address: u64) -> Result<String, String> (macos)
3737
```
3838
```
39-
pub fn pidpath(pid : i32) -> Result<String, String> (macos)
39+
pub fn pidpath(pid : i32) -> Result<String, String> (macos) (linux)
4040
```
4141
```
4242
pub fn libversion() -> Result<(i32, i32), String> (macos)

src/libproc/proc_pid.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{mem, process};
1313
use std::path::PathBuf;
1414
use std::ptr;
1515

16-
#[cfg(not(target_os = "macos"))]
16+
#[cfg(target_os = "linux")]
1717
use libc::PATH_MAX;
1818

1919
use libc::pid_t;
@@ -24,7 +24,9 @@ use crate::libproc::task_info::{TaskAllInfo, TaskInfo};
2424
use crate::libproc::thread_info::ThreadInfo;
2525
use crate::libproc::work_queue_info::WorkQueueInfo;
2626

27-
use self::libc::{c_char, c_int, c_void, readlink};
27+
#[cfg(target_os = "linux")]
28+
use self::libc::{c_char, readlink};
29+
use self::libc::{c_int, c_void};
2830

2931
// Since we cannot access C macros for constants from Rust - I have had to redefine this, based on Apple's source code
3032
// See http://opensource.apple.com/source/Libc/Libc-594.9.4/darwin/libproc.c
@@ -572,7 +574,6 @@ mod test {
572574
}
573575
}
574576

575-
//
576577
#[test]
577578
// This checks that it cannot find the path of the process with pid -1 and returns correct error messaage
578579
fn pidpath_test_unknown_pid() {
@@ -598,4 +599,4 @@ mod test {
598599
fn test_pidcwd_of_self() {
599600
assert_eq!(env::current_dir().unwrap(), pidcwd(process::id() as i32).unwrap());
600601
}
601-
}
602+
}

0 commit comments

Comments
 (0)