Struct processes::ProcessKillGuard
source · pub struct ProcessKillGuard(pub OwnedProcess);Expand description
A guard wrapping a OwnedProcess that will be automatically killed on drop.
Tuple Fields§
§0: OwnedProcessMethods from Deref<Target = OwnedProcess>§
sourcepub fn borrowed(&self) -> BorrowedProcess<'_>
pub fn borrowed(&self) -> BorrowedProcess<'_>
Returns a borrowed instance of this process.
sourcepub fn try_clone(&self) -> Result<Self, ProcessError>
pub fn try_clone(&self) -> Result<Self, ProcessError>
Trys to clone this process instance.
sourcepub fn try_to_owned(&self) -> Result<OwnedProcess, ProcessError>
pub fn try_to_owned(&self) -> Result<OwnedProcess, ProcessError>
Trys to create a new OwnedProcess instance for this process.
sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Returns whether this instance represents the current process.
sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Returns whether this process is still alive and running.
Note
If the operation to determine the status fails, this function assumes that the process has exited.
sourcepub fn pid(&self) -> Result<NonZeroU32, ProcessError>
pub fn pid(&self) -> Result<NonZeroU32, ProcessError>
Returns the id of this process.
sourcepub fn runs_under_wow64(&self) -> Result<bool, ProcessError>
pub fn runs_under_wow64(&self) -> Result<bool, ProcessError>
Returns whether this process is running under WOW64. This is the case for 32-bit programs running on a 64-bit platform.
sourcepub fn is_64_bit(&self) -> Result<bool, ProcessError>
pub fn is_64_bit(&self) -> Result<bool, ProcessError>
Returns whether this process is a 64-bit process.
sourcepub fn is_32_bit(&self) -> Result<bool, ProcessError>
pub fn is_32_bit(&self) -> Result<bool, ProcessError>
Returns whether this process is a 32-bit process.
sourcepub fn bitness(&self) -> Result<usize, ProcessError>
pub fn bitness(&self) -> Result<usize, ProcessError>
Returns the bitness of this process.
sourcepub fn path(&self) -> Result<PathBuf, ProcessError>
pub fn path(&self) -> Result<PathBuf, ProcessError>
Returns the executable path of this process.
sourcepub fn base_name(&self) -> Result<String, ProcessError>
pub fn base_name(&self) -> Result<String, ProcessError>
Returns the file name of the executable of this process.
sourcepub fn base_name_os(&self) -> Result<OsString, ProcessError>
pub fn base_name_os(&self) -> Result<OsString, ProcessError>
Returns the file name of the executable of this process as an OsString.
sourcepub fn kill(&self) -> Result<(), ProcessError>
pub fn kill(&self) -> Result<(), ProcessError>
Terminates this process with exit code 1.
sourcepub fn kill_with_exit_code(&self, exit_code: u32) -> Result<(), ProcessError>
pub fn kill_with_exit_code(&self, exit_code: u32) -> Result<(), ProcessError>
Terminates this process with the given exit code.
sourcepub fn run_remote_thread<T>(
&self,
remote_fn: extern "system" fn(_: *mut T) -> u32,
parameter: *mut T
) -> Result<u32, ProcessError>
pub fn run_remote_thread<T>( &self, remote_fn: extern "system" fn(_: *mut T) -> u32, parameter: *mut T ) -> Result<u32, ProcessError>
Starts a new thread in this process with the given entry point and argument, and waits for it to finish, returning the exit code.
sourcepub fn start_remote_thread<T>(
&self,
remote_fn: unsafe extern "system" fn(_: *mut T) -> u32,
parameter: *mut T
) -> Result<OwnedHandle, ProcessError>
pub fn start_remote_thread<T>( &self, remote_fn: unsafe extern "system" fn(_: *mut T) -> u32, parameter: *mut T ) -> Result<OwnedHandle, ProcessError>
Starts a new thread in this process with the given entry point and argument and returns the thread handle.
sourcepub fn modules(&self) -> Result<Vec<ProcessModule<Handle>>, ProcessError>
pub fn modules(&self) -> Result<Vec<ProcessModule<Handle>>, ProcessError>
Returns a snapshot of all modules currently loaded in this process.
Note
If the process is currently starting up and has not loaded all its modules yet, the returned list may be incomplete.
sourcepub fn module_handles(
&self
) -> Result<impl Iterator<Item = Result<ModuleHandle, ProcessError>> + '_, ProcessError>
pub fn module_handles( &self ) -> Result<impl Iterator<Item = Result<ModuleHandle, ProcessError>> + '_, ProcessError>
Returns a snapshot of the handles of the modules currently loaded in this process.
Note
If the process is currently starting up and has not yet loaded all its modules, the returned list may be incomplete. This can be worked around by repeatedly calling this method.
sourcepub fn main_module(&self) -> Result<ProcessModule<Handle>, ProcessError>where
Self: Sized,
pub fn main_module(&self) -> Result<ProcessModule<Handle>, ProcessError>where Self: Sized,
Returns the main module of this process. This is typically the executable.
sourcepub fn find_module_by_name(
&self,
module_name: impl AsRef<Path>
) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
pub fn find_module_by_name( &self, module_name: impl AsRef<Path> ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
Searches the modules in this process for one with the given name.
The comparison of names is case-insensitive.
If the extension is omitted, the default library extension .dll is appended.
Note
If the process is currently starting up and has not loaded all its modules, the returned list may be incomplete.
See also Process::wait_for_module_by_name.
sourcepub fn find_module_by_path(
&self,
module_path: impl AsRef<Path>
) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
pub fn find_module_by_path( &self, module_path: impl AsRef<Path> ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
Searches the modules in this process for one with the given path.
The comparison of paths is case-insensitive.
If the extension is omitted, the default library extension .dll is appended.
Note
If the process is currently starting up and has not loaded all its modules, the returned list may be incomplete.
See also Process::wait_for_module_by_path.
sourcepub fn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration
) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
pub fn wait_for_module_by_name( &self, module_name: impl AsRef<Path>, timeout: Duration ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
Searches the modules in this process for one with the given name repeatedly until a matching module is found or the given timeout elapses.
The comparison of names is case-insensitive.
If the extension is omitted, the default library extension .dll is appended.
sourcepub fn wait_for_module_by_path(
&self,
module_path: impl AsRef<Path>,
timeout: Duration
) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
pub fn wait_for_module_by_path( &self, module_path: impl AsRef<Path>, timeout: Duration ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>
Searches the modules in this process for one with the given path repeatedly until a matching module is found or the given timeout elapses.
The comparison of paths is case-insensitive.
If the extension is omitted, the default library extension .dll is appended.