Skip to main content

ProcessInfo

Struct ProcessInfo 

Source
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

Source

pub fn pid(&self) -> u32

Returns the process ID.

Source

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.

Source

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.

Source

pub fn start_time(&self) -> StartTime

Returns when the process started.

Source

pub fn exe(&self) -> Option<Path<'_>>

Returns the path to the process executable.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn session(&self) -> Uuid

Returns the identity of the target session this was captured from.

Trait Implementations§

Source§

impl Clone for ProcessInfo

Source§

fn clone(&self) -> ProcessInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProcessInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ProcessInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ProcessInfo

Source§

impl PartialEq for ProcessInfo

Source§

fn eq(&self, other: &ProcessInfo) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ProcessInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ProcessInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.