[][src]Struct heim_process::Process

pub struct Process(_);

System process.

Some extra methods can be found in the OS extensions

Implementations

impl Process[src]

pub fn pid(&self) -> Pid[src]

Returns the process pid.

pub async fn parent_pid<'_>(&'_ self) -> ProcessResult<Pid>[src]

Returns process parent pid.

pub async fn parent<'_>(&'_ self) -> ProcessResult<Process>[src]

Returns parent Process.

pub async fn name<'_>(&'_ self) -> ProcessResult<String>[src]

Returns process name.

pub async fn exe<'_>(&'_ self) -> ProcessResult<PathBuf>[src]

Returns process executable as an absolute path.

pub async fn command<'_>(&'_ self) -> ProcessResult<Command>[src]

Returns process command line.

Example

let process = process::current().await?;
let command = process.command().await?;
println!("Command line arguments:");
for arg in &command {
    println!("{:?}", arg);
}

pub async fn cwd<'_>(&'_ self) -> ProcessResult<PathBuf>[src]

Returns process current working directory.

Compatibility

For Windows this method is not implemented yet and will always panic, see #105.

pub async fn status<'_>(&'_ self) -> ProcessResult<Status>[src]

Returns current process status.

pub async fn environment<'_>(&'_ self) -> ProcessResult<Environment>[src]

Returns process environment.

pub async fn create_time<'_>(&'_ self) -> ProcessResult<Time>[src]

Returns process creation time, expressed as a Time amount since the UNIX epoch.

pub async fn cpu_time<'_>(&'_ self) -> ProcessResult<CpuTime>[src]

Returns accumulated process time.

pub async fn cpu_usage<'_>(&'_ self) -> ProcessResult<CpuUsage>[src]

Returns CPU usage measurement.

Returned CpuUsage struct represents instantaneous CPU usage and does not represent any reasonable value by itself. It is suggested to wait for a while with help of any async timer (for accuracy recommended delay should be at least 100 ms), call this method once again and subtract former CpuUsage from the new one.

Same to any *nix system, calculated CPU usage might exceed 100 % if the process is running multiple threads on different CPU cores.

Example

let process = process::current().await?;
let measurement_1 = process.cpu_usage().await?;
// Or any other async timer at your choice
futures_timer::Delay::new(Duration::from_millis(100)).await;
let measurement_2 = process.cpu_usage().await?;

println!("CPU usage: {} %", (measurement_2 - measurement_1).get::<ratio::percent>());

pub async fn memory<'_>(&'_ self) -> ProcessResult<Memory>[src]

Returns memory usage information for this process.

pub async fn is_running<'_>(&'_ self) -> ProcessResult<bool>[src]

Checks if this Process is still running.

pub async fn suspend<'_>(&'_ self) -> ProcessResult<()>[src]

Suspends the current process.

Before the signal send, it checks whether process PID has been reused, and if it is a case, NoSuchProcess error will be returned.

Compatibility

For *nix systems it sends the SIGSTOP signal to process.

pub async fn resume<'_>(&'_ self) -> ProcessResult<()>[src]

Resumes the current process.

Before the signal send, it checks whether process PID has been reused, and if it is a case, NoSuchProcess error will be returned.

Compatibility

For *nix systems it sends the SIGCONT signal to process.

pub async fn terminate<'_>(&'_ self) -> ProcessResult<()>[src]

Terminates the current process.

Before the signal send, it checks whether process PID has been reused, and if it is a case, NoSuchProcess error will be returned.

Compatibility

For *nix systems it sends the SIGTERM signal to process.

For Windows it is an alias for the Process::kill

pub async fn kill<'_>(&'_ self) -> ProcessResult<()>[src]

Kills the current process.

Before the signal send, it checks whether process PID has been reused, and if it is a case, NoSuchProcess error will be returned.

Compatibility

For *nix systems it sends the SIGKILL signal to process.

TerminateProcess function is used for Windows, it initiates the termination but does not awaits for completion.

pub async fn wait<'_>(&'_ self) -> ProcessResult<()>[src]

Wait for the current process termination.

Returns

If the process is already terminated, this method returns Ok(()).

pub async fn io_counters<'_>(&'_ self) -> ProcessResult<IoCounters>[src]

Returns future which resolves into process IO counters.

Trait Implementations

impl Debug for Process[src]

impl Eq for Process[src]

impl Hash for Process[src]

impl PartialEq<Process> for Process[src]

impl ProcessExt for Process[src]

This is supported on Unix only.

impl ProcessExt for Process[src]

This is supported on Linux only.

impl StructuralEq for Process[src]

impl StructuralPartialEq for Process[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.