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
impl OwnedProcess
sourcepub fn from_pid(pid: u32) -> Result<OwnedProcess, ProcessError>
pub fn from_pid(pid: u32) -> Result<OwnedProcess, ProcessError>
Creates a new instance from the given pid.
sourcepub unsafe fn from_pid_with_access(
pid: u32,
access: u32
) -> Result<OwnedProcess, ProcessError>
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.
sourcepub fn all() -> Result<impl Iterator<Item = OwnedProcess>, ProcessError>
pub fn all() -> Result<impl Iterator<Item = OwnedProcess>, ProcessError>
Returns a list of all currently running processes.
sourcepub fn find_all_by_name(
name: impl AsRef<str>
) -> Result<impl Iterator<Item = OwnedProcess>, ProcessError>
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.
sourcepub fn find_first_by_name(
name: impl AsRef<str>
) -> Result<Option<OwnedProcess>, ProcessError>
pub fn find_first_by_name( name: impl AsRef<str> ) -> Result<Option<OwnedProcess>, ProcessError>
Finds the first process whose name contains the given string.
sourcepub fn from_child(child: Child) -> OwnedProcess
pub fn from_child(child: Child) -> OwnedProcess
Creates a new instance from the given child process.
sourcepub fn leak(self) -> BorrowedProcess<'static>
pub fn leak(self) -> BorrowedProcess<'static>
Leaks the underlying handle and return it as a non-owning BorrowedProcess
instance.
sourcepub const fn kill_on_drop(self) -> ProcessKillGuard
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
impl From<Child> for OwnedProcess
source§impl TryFrom<Process<BorrowedHandle<'_>>> for OwnedProcess
impl TryFrom<Process<BorrowedHandle<'_>>> for OwnedProcess
§type Error = ProcessError
type Error = ProcessError
The type returned in the event of a conversion error.