diff options
| author | namilsk <namilsk@namilsk.tech> | 2026-02-02 21:53:28 +0300 |
|---|---|---|
| committer | namilsk <namilsk@namilsk.tech> | 2026-02-02 21:53:28 +0300 |
| commit | 913da896fcc161b138932655c3c7864cbde3d6a7 (patch) | |
| tree | 70cb662460b4857b5ec3f16dc7f37401d74093c7 /init | |
| parent | 6a63e7e777fb9182ff5b68aa2167bd5f2e548f0e (diff) | |
Added exit-code check before restarting service
Diffstat (limited to 'init')
| -rw-r--r-- | init/src/services/units.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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<dyn std::error::Error + Send>> { 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<dyn std::error::Error + Send>)?; |
