A lightweight Linux Process Monitor written in C that demonstrates how modern operating systems expose process information through the /proc virtual filesystem.
The project reads process metadata directly from the Linux kernel, computes real-time CPU utilization, monitors memory usage, supports interactive sorting and filtering, and presents the information in a terminal-based user interface using ncurses.
Inspired by utilities such as top and ps, this project was implemented entirely from scratch for learning Operating Systems, Linux System Programming, and Process Management.
- Enumerates all running processes from the
/procfilesystem - Reads process information directly from
/proc/[pid]/status - Displays:
- Process ID (PID)
- Process Name
- Process State
- Physical Memory Usage (VmRSS)
- Handles processes that terminate during enumeration safely
- Real-time CPU utilization calculation
- Live memory monitoring
- Interactive terminal interface using ncurses
- Refreshes every second
- Sort processes by:
- CPU Usage
- Memory Usage
- Process ID
- Filter processes by name
- Highlight high CPU usage processes
- Responsive non-blocking keyboard controls
The animation below demonstrates the real-time monitoring interface, highlighting live process updates, interactive sorting capabilities, and terminal-based navigation.
Demonstrated sequence: Sort by CPU (c) → Sort by Memory (m) → Sort by PID (p) → Exit (q)
The monitor gathers information directly from the Linux kernel without relying on external utilities.
Reads:
/proc/[pid]/status
to obtain:
- Process Name
- Process State
- Resident Memory (VmRSS)
Reads:
/proc/[pid]/stat
to obtain:
- User CPU Time
- Kernel CPU Time
Reads:
/proc/stat
to obtain total CPU time.
CPU usage is computed by comparing two snapshots separated by one second.
- C
- Linux
- POSIX APIs
/procFilesystem- ncurses
- GCC
- Process Management
- Linux
/procVirtual Filesystem - System Calls
- File I/O
- Directory Traversal
- Terminal User Interfaces (TUI)
- CPU Scheduling Statistics
- Memory Monitoring
- Process Enumeration
- Real-Time Monitoring
ProcessMonitor/
│
├── phase1.c # Process enumeration
├── phase2.c # Real-time process monitor
├── README.md
├── LICENSE
└── .gitignore
gcc phase1.c -o phase1gcc phase2.c -o phase2 -lncurses./phase1./phase2Filter by process name:
./phase2 chrome| Key | Action |
|---|---|
c |
Sort by CPU Usage |
m |
Sort by Memory Usage |
p |
Sort by PID |
q |
Quit |
PID NAME STATE CPU% MEMORY(KB)
2312 chrome S 21.4 218432
1821 gnome-shell S 8.6 174020
1120 systemd S 0.2 14384
...
- Linux System Programming
- Operating Systems
- Process Management
- Terminal UI Development
- Parsing Kernel Data Structures
- File Handling
- Data Structures
- Sorting Algorithms
- Real-Time System Monitoring
- C Programming
- Multi-core CPU utilization
- Process tree visualization
- Thread information
- Network connection monitoring
- Per-process disk I/O statistics
- Search inside the interface
- Interactive process termination
- Export statistics to CSV
- Color themes
- Historical CPU graphs
This project was built to gain practical experience with:
- Linux process management
- Operating System internals
- The
/procvirtual filesystem - CPU usage calculation
- Memory monitoring
- Real-time terminal applications
- Linux system programming in C
This project is licensed under the MIT License.
Teja Sai Eswar
B.Tech, Department of Electronics and Electrical Communication Engineering
Indian Institute of Technology Kharagpur
