This Rust program is a basic implementation of the ps command, which lists running processes on a Linux system by reading the /proc filesystem.
The program performs the following tasks:
- Read process directories from
/proc, filtering numeric PIDs. - Parse
/proc/[pid]/statusto extract:- Name (process name)
- VmRSS (memory usage in KB)
- Threads (number of threads)
- Display process details including PID, name, memory usage, and thread count.
Processstruct: Represents a process and gathers process information.Statusstruct: Parses and stores process details from/proc/[pid]/status.- Functions:
Process::process_list(): Reads processes from/proc.Status::parse(pid): Parses status file for details.Status::display_memory(): Formats memory output.