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

pub struct Process(_);
This is supported on crate 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]

Returns the process pid.

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

Returns process parent pid.

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

Returns parent Process.

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

Returns process name.

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

Returns process executable as an absolute path.

pub async fn command(&'_ self) -> Result<Command, ProcessError>[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) -> Result<PathBuf, ProcessError>[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) -> Result<Status, ProcessError>[src]

Returns current process status.

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

Returns process environment.

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

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

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

Returns accumulated process time.

pub async fn cpu_usage(&'_ self) -> Result<CpuUsage, ProcessError>[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) -> Result<Memory, ProcessError>[src]

Returns memory usage information for this process.

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

Checks if this Process is still running.

pub async fn suspend(&'_ self) -> Result<(), ProcessError>[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) -> Result<(), ProcessError>[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) -> Result<(), ProcessError>[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) -> Result<(), ProcessError>[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) -> Result<(), ProcessError>[src]

Wait for the current process termination.

Returns

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

pub async fn io_counters(&'_ self) -> Result<IoCounters, ProcessError>[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]

impl ProcessExt for Process[src]

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.