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.
This commit is contained in:
sankalp committed 2026-05-25 14:50:17 +05:45
1 parent 74aa1ff262
commit 972618a8e3
1 file changed
+8 -3
+8 -3
View File
@@ -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(())
}