From 913da896fcc161b138932655c3c7864cbde3d6a7 Mon Sep 17 00:00:00 2001 From: namilsk Date: Mon, 2 Feb 2026 21:53:28 +0300 Subject: Added exit-code check before restarting service --- init/src/services/units.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'init') diff --git a/init/src/services/units.rs b/init/src/services/units.rs index 01c4183..6e3223e 100644 --- a/init/src/services/units.rs +++ b/init/src/services/units.rs @@ -14,7 +14,7 @@ use crate::{RUNLEVEL_STATE, log_warning}; use serde::Deserialize; use std::{ fs::{read_dir, read_to_string}, - process::Child, + process::{Child, ExitStatus}, time::Duration, }; @@ -226,7 +226,7 @@ pub fn services_mainloop() -> Result<(), Box> { for i in 0..pids.len() { match pids[i].0.try_wait() { Ok(Some(status)) => { - if pids[i].2 == Restart::Always && pids[i].3 < 3 { + if pids[i].2 == Restart::Always && pids[i].3 < 3 && status.code() != Some(0) { let new_child = std::process::Command::new(pids[i].1.clone()) .spawn() .map_err(|e| Box::new(e) as Box)?; -- cgit v1.2.3