pub struct ProcessInfo { /* private fields */ }Expand description
A snapshot of one process, as of when it was taken.
Every field but pid, name, and start is optional, because no field
beyond those is available on every platform, for every target process, to
every caller. See the accessors for what limits each one.
Implementations§
Source§impl ProcessInfo
impl ProcessInfo
Sourcepub fn parent_pid(&self) -> Option<u32>
pub fn parent_pid(&self) -> Option<u32>
Returns the parent process ID.
The process that created this one, which may have exited since. Unix
reparents an orphan to init and so reports a live process; Windows
keeps reporting the original creator, whose PID may by then belong to
something unrelated.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the process name.
The kernel’s short name for the process, not its executable path: Linux and the BSDs truncate it, and it reflects whatever the process last set rather than what it was launched as.
Sourcepub fn start_time(&self) -> StartTime
pub fn start_time(&self) -> StartTime
Returns when the process started.
Sourcepub fn command_line(&self) -> Option<&[String]>
pub fn command_line(&self) -> Option<&[String]>
Returns the process command line.
Best-effort: macOS restricts it to processes owned by the same user.
On Windows this is a reconstruction. The kernel stores one string and
leaves splitting it to the process, so what is reported here is that
string split by the MSVC convention that Rust and every C runtime
follow — which is what the target process almost certainly did with it,
but not something the system guarantees. windows_command_line has
the original.
Sourcepub fn windows_command_line(&self) -> Result<Option<&str>>
pub fn windows_command_line(&self) -> Result<Option<&str>>
Returns the process command line as a single unsplit string.
Windows only, where this is the form the kernel actually stores.
§Errors
ErrorKind::Unsupported if the
record came from a Unix target, where the argument vector is what the
kernel holds and there is no original string to fall back to.
Sourcepub fn cwd(&self) -> Option<Path<'_>>
pub fn cwd(&self) -> Option<Path<'_>>
Returns the process working directory.
On Windows this is the process’s own bookkeeping rather than something the system tracks: NT has no per-process current directory, so what is reported is the Win32 one the target keeps in its own memory, read from there. A process is free to put anything in that field.
Sourcepub fn identity(&self) -> Result<Option<&UnixSecurityInfo>>
pub fn identity(&self) -> Result<Option<&UnixSecurityInfo>>
Returns the process’s Unix credentials.
The group list holds the supplementary groups alone. The BSDs keep the
effective group in the first slot of the credential’s group array and
report it that way, so it is dropped here to leave the field meaning
the same thing on every target — it is reported by
UnixSecurityInfo::effective_gid instead.
On macOS the supplementary group list is the kernel credential list,
capped at NGROUPS (16). That is narrower than what
SecurityInfo::current
reports for this process, which resolves extended memberships through
opendirectoryd — an interface that answers only for the caller — so a
foreign macOS group list can be a truncated view where the
current-process one is not.
§Errors
ErrorKind::Unsupported if the
record came from a Windows target, which has no such credentials to
report.
Sourcepub fn token(&self) -> Result<Option<&WindowsTokenInfo>>
pub fn token(&self) -> Result<Option<&WindowsTokenInfo>>
Returns the process’s access token information.
None where it could not be read, which every route reports the same
way: a process that refuses to be opened, or one whose token the caller
has no right to. Nothing about which call produced the record changes
what is here.
§Errors
ErrorKind::Unsupported if the
record came from a Unix target, which has no access tokens.
Sourcepub fn exit(&self) -> Option<ProcessExit>
pub fn exit(&self) -> Option<ProcessExit>
Returns how the process ended, or None if it was still running.
A process can outlive itself in the table: Unix keeps a zombie until its parent reaps it, and Windows keeps an exited process addressable while any handle to it remains open. Such a record still reports what the kernel holds — the PID, the parent, when it started — while everything read out of its address space, the command line and working directory included, is gone. This is what distinguishes that from a live process whose fields were merely denied.
Only Windows reports a code, for the reason ProcessExit gives.
None is also what a record carries when its process could not be
examined closely enough to tell, which on Windows means one that could
not be opened at all.
Trait Implementations§
Source§impl Clone for ProcessInfo
impl Clone for ProcessInfo
Source§fn clone(&self) -> ProcessInfo
fn clone(&self) -> ProcessInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProcessInfo
impl Debug for ProcessInfo
Source§impl<'de> Deserialize<'de> for ProcessInfo
impl<'de> Deserialize<'de> for ProcessInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ProcessInfo
Source§impl PartialEq for ProcessInfo
impl PartialEq for ProcessInfo
Source§impl Serialize for ProcessInfo
impl Serialize for ProcessInfo
impl StructuralPartialEq for ProcessInfo
Auto Trait Implementations§
impl Freeze for ProcessInfo
impl RefUnwindSafe for ProcessInfo
impl Send for ProcessInfo
impl Sync for ProcessInfo
impl Unpin for ProcessInfo
impl UnsafeUnpin for ProcessInfo
impl UnwindSafe for ProcessInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more