A lightweight Smart Process Watchdog in C++ that monitors a target process, auto-restarts it on crash, and can detect resource anomalies (memory spikes). Designed as a learning project to understand process management, signals, /proc parsing, and basic supervision logic.
- Spawn target process using
fork+execvp - Detect child exit/crash via
waitpid - Monitor memory usage via
/proc/<pid>/status(VmRSS) - Auto-restart with configurable restart limits and windows
- Simple trend detection (memory increase warnings)
- Logging to
logs/watchdog.log - Optional daemon mode
Install build dependencies:
sudo pacman -S base-devel gcc# Build the watchdog and test applications
make
# Run the watchdog
./watchdog config/config.json
# Monitor logs in real-time
tail -f logs/watchdog.log
# Optional: Install system-wide
sudo make install
# Optional: Uninstall
sudo make uninstall