From 972618a8e3f1e7ef5944b58ed9f4dc446d81d589 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 25 May 2026 14:50:17 +0545 Subject: [PATCH] fix(src/hardware): improveerror handling for GPU process killing New Features - Added explicit error handling and logging for `fuser` command failures. Enhancements - Refined process termination logic with richer diagnostics and graceful degradation when tools are unavailable. Bug Fixes - Prevented silent failures when stopping `nvidia-persistenced.service` by logging errors instead of ignoring them. --- src/hardware/gpu.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hardware/gpu.rs b/src/hardware/gpu.rs index ed6ac47..53cc83d 100644 --- a/src/hardware/gpu.rs +++ b/src/hardware/gpu.rs @@ -119,12 +119,17 @@ pub fn rescan_pci() -> Result<(), String> { pub fn kill_gpu_processes() -> Result<(), String> { info!("Killing processes using NVIDIA GPU..."); // Try using fuser first as it is more likely to be available and easy to use - let _ = Command::new("fuser").args(["-k", "/dev/nvidia*"]).output(); + if let Err(e) = Command::new("fuser").args(["-k", "/dev/nvidia*"]).output() { + log::warn!("fuser failed (may not be installed): {}", e); + } // Also kill specific nvidia services if they are running - let _ = Command::new("systemctl") + if let Err(e) = Command::new("systemctl") .args(["stop", "nvidia-persistenced.service"]) - .output(); + .output() + { + log::debug!("Failed to stop nvidia-persistenced: {}", e); + } Ok(()) }