src/tools/procfs.rs: use libc::pid_t
This commit is contained in:
parent
d3d7ab1273
commit
52ddc2522d
|
@ -13,7 +13,7 @@ pub struct ProcFsPidStat {
|
||||||
pub rss: i64,
|
pub rss: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_proc_pid_stat(pid: nix::unistd::Pid) -> Result<ProcFsPidStat, Error> {
|
pub fn read_proc_pid_stat(pid: libc::pid_t) -> Result<ProcFsPidStat, Error> {
|
||||||
|
|
||||||
let statstr = tools::file_read_firstline(format!("/proc/{}/stat", pid))?;
|
let statstr = tools::file_read_firstline(format!("/proc/{}/stat", pid))?;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ pub fn read_proc_pid_stat(pid: nix::unistd::Pid) -> Result<ProcFsPidStat, Error>
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(cap) = REGEX.captures(&statstr) {
|
if let Some(cap) = REGEX.captures(&statstr) {
|
||||||
if pid != nix::unistd::Pid::from_raw(cap["pid"].parse::<i32>().unwrap()) {
|
if pid != cap["pid"].parse::<i32>().unwrap() {
|
||||||
bail!("unable to read pid stat for process '{}' - got wrong pid", pid);
|
bail!("unable to read pid stat for process '{}' - got wrong pid", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ pub fn read_proc_pid_stat(pid: nix::unistd::Pid) -> Result<ProcFsPidStat, Error>
|
||||||
bail!("unable to read pid stat for process '{}'", pid);
|
bail!("unable to read pid stat for process '{}'", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_proc_starttime(pid: nix::unistd::Pid) -> Result<u64, Error> {
|
pub fn read_proc_starttime(pid: libc::pid_t) -> Result<u64, Error> {
|
||||||
|
|
||||||
let info = read_proc_pid_stat(pid)?;
|
let info = read_proc_pid_stat(pid)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue