pub struct Process {
pub pid: u32,
pub name: String,
pub exe_path: Option<String>,
pub cwd: Option<String>,
pub command: Option<String>,
pub cpu_percent: f32,
pub memory_mb: f64,
pub status: ProcessStatus,
pub user: Option<String>,
pub parent_pid: Option<u32>,
pub start_time: Option<u64>,
}Expand description
Represents a system process with relevant information
Fields§
§pid: u32Process ID
name: StringProcess name (executable name)
exe_path: Option<String>Path to the executable
cwd: Option<String>Current working directory
command: Option<String>Full command line (if available)
cpu_percent: f32CPU usage percentage (0.0 - 100.0+)
memory_mb: f64Memory usage in megabytes
status: ProcessStatusProcess status
user: Option<String>User who owns the process
parent_pid: Option<u32>Parent process ID
start_time: Option<u64>Process start time (Unix timestamp)
Implementations§
Source§impl Process
impl Process
Sourcepub fn find_by_name(pattern: &str) -> Result<Vec<Process>>
pub fn find_by_name(pattern: &str) -> Result<Vec<Process>>
Find all processes matching a name pattern (case-insensitive)
Sourcepub fn find_stuck(timeout: Duration) -> Result<Vec<Process>>
pub fn find_stuck(timeout: Duration) -> Result<Vec<Process>>
Find processes that appear to be stuck (high CPU, no progress) This is a heuristic-based detection
Sourcepub fn kill(&self) -> Result<()>
pub fn kill(&self) -> Result<()>
Force kill the process (SIGKILL on Unix, taskkill /F on Windows)
Sourcepub fn kill_and_wait(&self) -> Result<Option<ExitStatus>>
pub fn kill_and_wait(&self) -> Result<Option<ExitStatus>>
Force kill and wait for process to terminate Returns the exit status if available
Sourcepub fn terminate(&self) -> Result<()>
pub fn terminate(&self) -> Result<()>
Send SIGTERM for graceful termination (Unix) or taskkill (Windows)
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the process is still running (alias for exists for compatibility)
Sourcepub fn wait(&self) -> Option<ExitStatus>
pub fn wait(&self) -> Option<ExitStatus>
Wait for the process to terminate Returns the exit status if available