Type Definition processes::OwnedProcess

source ·
pub type OwnedProcess = Process<OwnedHandle>;
Expand description

A struct representing a running process. This struct owns the underlying process handle (see also BorrowedProcess for a borrowed version).

Implementations§

source§

impl OwnedProcess

source

pub fn from_pid(pid: u32) -> Result<OwnedProcess, ProcessError>

Creates a new instance from the given pid.

source

pub unsafe fn from_pid_with_access( pid: u32, access: u32 ) -> Result<OwnedProcess, ProcessError>

Creates a new instance from the given pid and the given privileges.

Safety

access must be a valid set of process-specific access rights.

source

pub fn all() -> Result<impl Iterator<Item = OwnedProcess>, ProcessError>

Returns a list of all currently running processes.

source

pub fn find_all_by_name( name: impl AsRef<str> ) -> Result<impl Iterator<Item = OwnedProcess>, ProcessError>

Finds all processes whose name contains the given string.

source

pub fn find_first_by_name( name: impl AsRef<str> ) -> Result<Option<OwnedProcess>, ProcessError>

Finds the first process whose name contains the given string.

source

pub fn from_child(child: Child) -> OwnedProcess

Creates a new instance from the given child process.

source

pub fn leak(self) -> BorrowedProcess<'static>

Leaks the underlying handle and return it as a non-owning BorrowedProcess instance.

source

pub const fn kill_on_drop(self) -> ProcessKillGuard

Returns a ProcessKillGuard wrapping this process that will automatically kill this process when dropped.

Trait Implementations§

source§

impl From<Child> for OwnedProcess

source§

fn from(child: Child) -> Self

Converts to this type from the input type.
source§

impl TryFrom<Process<BorrowedHandle<'_>>> for OwnedProcess

§

type Error = ProcessError

The type returned in the event of a conversion error.
source§

fn try_from(process: BorrowedProcess<'_>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Send for OwnedProcess

source§

impl Sync for OwnedProcess