[][src]Struct heim::process::Process

pub struct Process(_);
This is supported on feature="process" only.

System process.

Some extra methods can be found in the OS extensions

Implementations

impl Process[src]

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

This is supported on feature="process" only.

Returns the process pid.

pub async fn parent_pid(&'_ self) -> Result<i32, ProcessError>[src]

This is supported on feature="process" only.

Returns process parent pid.

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

This is supported on feature="process" only.

Returns parent Process.

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

This is supported on feature="process" only.

Returns process name.

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

This is supported on feature="process" only.

Returns process executable as an absolute path.

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

This is supported on feature="process" only.

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) -> Result<PathBuf, ProcessError>[src]

This is supported on feature="process" only.

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) -> Result<Status, ProcessError>[src]

This is supported on feature="process" only.

Returns current process status.

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

This is supported on feature="process" only.

Returns process environment.

pub async fn create_time(
    &'_ self
) -> Result<Quantity<dyn Dimension<J = Z0, N = Z0, T = PInt<UInt<UTerm, B1>>, I = Z0, L = Z0, M = Z0, Kind = dyn Kind + 'static, Th = Z0> + 'static, dyn Units<f64, time = second, thermodynamic_temperature = kelvin, length = meter, electric_current = ampere, amount_of_substance = mole, luminous_intensity = candela, mass = kilogram> + 'static, f64>, ProcessError>
[src]

This is supported on feature="process" only.

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

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

This is supported on feature="process" only.

Returns accumulated process time.

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

This is supported on feature="process" only.

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) -> Result<Memory, ProcessError>[src]

This is supported on feature="process" only.

Returns memory usage information for this process.

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

This is supported on feature="process" only.

Checks if this Process is still running.

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

This is supported on feature="process" only.

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) -> Result<(), ProcessError>[src]

This is supported on feature="process" only.

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) -> Result<(), ProcessError>[src]

This is supported on feature="process" only.

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) -> Result<(), ProcessError>[src]

This is supported on feature="process" only.

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) -> Result<(), ProcessError>[src]

This is supported on feature="process" only.

Wait for the current process termination.

Returns

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

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]

impl ProcessExt for Process[src]

impl StructuralEq for Process[src]

impl StructuralPartialEq for Process[src]

Auto Trait Implementations

impl RefUnwindSafe for Process

impl Send for Process

impl Sync for Process

impl Unpin for Process

impl UnwindSafe for Process

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.