Skip to content

Commit cb38adc

Browse files
Merge pull request #28 from andrewdavidmackenzie/libproc-rs-18
libproc-rs-18
2 parents 34c43b6 + f01d924 commit cb38adc

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ os:
99
- linux
1010
- osx
1111

12+
branches:
13+
only:
14+
- "master"
15+
1216
matrix:
1317
allow_failures:
1418
- os: linux

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ Run "cargo doc" and then open "./target/doc/libproc/index.html".
2323
More documentation will be added over time.
2424

2525
# API
26-
At the moment these methods are implemented:
26+
At the moment these methods have been implemented:
27+
28+
## Process / PID related
2729
```
2830
pub fn listpids(proc_types: ProcType) -> Result<Vec<u32>, String>
2931
```
3032
```
33+
pub fn pidinfo<T: PIDInfo>(pid : i32, arg: u64) -> Result<T, String> {
34+
```
35+
```
3136
pub fn regionfilename(pid: i32, address: u64) -> Result<String, String>
3237
```
3338
```
@@ -39,7 +44,21 @@ pub fn libversion() -> Result<(i32, i32), String>
3944
```
4045
pub fn name(pid: i32) -> Result<String, String>
4146
```
47+
```
48+
pub fn listpidinfo<T: ListPIDInfo>(pid : i32, max_len: usize) -> Result<Vec<T::Item>, String>
49+
```
50+
51+
## File and FileDescriptor related
52+
```
53+
pub fn pidfdinfo<T: PIDFDInfo>(pid : i32, fd: i32) -> Result<T, String>
54+
```
55+
56+
## PID Resource Usage related
57+
```
58+
pub fn pidrusage<T: PIDRUsage>(pid : i32) -> Result<T, String>
59+
```
4260

61+
## kmsgbuf
4362
I have also implemented this method - but the MAGIC_NUMBER returned is not correct,
4463
and upon investigation it seems that Apple/Darwin/Mach have changed totally how dmessage works in
4564
latest versions, moving away from using libproc to use kvm - with a total rewrite of dmesg.
@@ -59,10 +78,14 @@ pub fn kmsgbuf() -> Result<String, String>
5978
Initially just for Mac OS X.
6079

6180
# TODO
81+
See the [list of issues](https://github.com/andrewdavidmackenzie/libproc-rs/issues).
82+
I put the "help wanted" label where I need help from others.
83+
6284
- Complete the API on Mac OS X - figuring out all the Mac OS X / Darwin version mess....
6385
- Add more documentation (including samples with documentation test)
6486
- Add own custom error type and implement From::from to ease reporting of multiple error types in clients
65-
- Once the API is complete then doing a Linux version with the same API would make sense.
87+
- Once the API is complete then doing a Linux version with the same API would make sense,
88+
starting with simpler or more similar methods, and then abstratcion over apple/unix/linux would be needed
6689

6790
# LICENSE
6891
This code is licensed under MIT license (see LICENCE).

src/libproc/pid_rusage.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ extern {
4343
/// }
4444
/// }
4545
/// ```
46-
///
4746
pub fn pidrusage<T: PIDRUsage>(pid : i32) -> Result<T, String> {
4847
let flavor = T::flavor() as i32;
4948
let mut pidrusage = T::default();

src/libproc/proc_pid.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,15 @@ pub fn name(pid: i32) -> Result<String, String> {
318318
/// use libproc::libproc::proc_pid::{listpidinfo, pidinfo};
319319
/// use libproc::libproc::task_info::{TaskAllInfo};
320320
/// use libproc::libproc::file_info::{ListFDs, ProcFDType};
321+
/// use std::process;
321322
///
322-
/// fn listpidinfo_test() {
323-
/// use std::process;
324-
/// let pid = process::id() as i32;
323+
/// let pid = process::id() as i32;
325324
///
326-
/// if let Ok(info) = pidinfo::<TaskAllInfo>(pid, 0) {
327-
/// if let Ok(fds) = listpidinfo::<ListFDs>(pid, info.pbsd.pbi_nfiles as usize) {
328-
/// for fd in &fds {
329-
/// let fd_type = ProcFDType::from(fd.proc_fdtype);
330-
/// println!("File Descriptor: {}, Type: {:?}", fd.proc_fd, fd_type);
331-
/// }
325+
/// if let Ok(info) = pidinfo::<TaskAllInfo>(pid, 0) {
326+
/// if let Ok(fds) = listpidinfo::<ListFDs>(pid, info.pbsd.pbi_nfiles as usize) {
327+
/// for fd in &fds {
328+
/// let fd_type = ProcFDType::from(fd.proc_fdtype);
329+
/// println!("File Descriptor: {}, Type: {:?}", fd.proc_fd, fd_type);
332330
/// }
333331
/// }
334332
/// }

0 commit comments

Comments
 (0)