[][src]Trait sysinfo::ProcessExt

pub trait ProcessExt: Debug {
    fn kill(&self, signal: Signal) -> bool;
fn name(&self) -> &str;
fn cmd(&self) -> &[String];
fn exe(&self) -> &Path;
fn pid(&self) -> Pid;
fn environ(&self) -> &[String];
fn cwd(&self) -> &Path;
fn root(&self) -> &Path;
fn memory(&self) -> u64;
fn virtual_memory(&self) -> u64;
fn parent(&self) -> Option<Pid>;
fn status(&self) -> ProcessStatus;
fn start_time(&self) -> u64;
fn cpu_usage(&self) -> f32; }

Contains all the methods of the Process struct.

Required methods

fn kill(&self, signal: Signal) -> bool

Sends the given signal to the process.

use sysinfo::{ProcessExt, Signal, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    process.kill(Signal::Kill);
}

fn name(&self) -> &str

Returns the name of the process.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}", process.name());
}

fn cmd(&self) -> &[String]

Returns the command line.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{:?}", process.cmd());
}

fn exe(&self) -> &Path

Returns the path to the process.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}", process.exe().display());
}

fn pid(&self) -> Pid

Returns the pid of the process.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}", process.pid());
}

fn environ(&self) -> &[String]

Returns the environment of the process.

Always empty on Windows, except for current process.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{:?}", process.environ());
}

fn cwd(&self) -> &Path

Returns the current working directory.

Always empty on Windows.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}", process.cwd().display());
}

fn root(&self) -> &Path

Returns the path of the root directory.

Always empty on Windows.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}", process.root().display());
}

fn memory(&self) -> u64

Returns the memory usage (in KiB).

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{} KiB", process.memory());
}

fn virtual_memory(&self) -> u64

Returns the virtual memory usage (in KiB).

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{} KiB", process.virtual_memory());
}

fn parent(&self) -> Option<Pid>

Returns the parent pid.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{:?}", process.parent());
}

fn status(&self) -> ProcessStatus

Returns the status of the processus.

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{:?}", process.status());
}

fn start_time(&self) -> u64

Returns the time of process launch (in seconds).

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("Running since {} seconds", process.start_time());
}

fn cpu_usage(&self) -> f32

Returns the total CPU usage (in %).

use sysinfo::{ProcessExt, System, SystemExt};

let s = System::new();
if let Some(process) = s.get_process(1337) {
    println!("{}%", process.cpu_usage());
}
Loading content...

Implementors

impl ProcessExt for Process[src]

fn status(&self) -> ProcessStatus[src]

Returns the status of the processus (idle, run, zombie, etc). None means that sysinfo doesn't have enough rights to get this information.

Loading content...