From 6a63e7e777fb9182ff5b68aa2167bd5f2e548f0e Mon Sep 17 00:00:00 2001 From: namilsk Date: Mon, 2 Feb 2026 00:19:48 +0300 Subject: Implemented mainloop functions (e.g. restarting services), autofmt all --- init/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'init/src/main.rs') diff --git a/init/src/main.rs b/init/src/main.rs index 40e47a4..fa7d086 100644 --- a/init/src/main.rs +++ b/init/src/main.rs @@ -4,8 +4,8 @@ mod log; mod mounts; mod pid_one; mod processes; -mod signals; mod services; +mod signals; use crate::host::locale; use crate::host::set::set_hostname; @@ -15,17 +15,19 @@ use crate::mounts::fstab::FstabEntry; use crate::mounts::rescue; use crate::pid_one::check_pid; use crate::processes::udev::spawn_udev; -use crate::services::unit_parser::Runlevel; +use crate::services::units::{Runlevel, services_mainloop}; use crate::signals::sigchld; // RULE: I will not use .expect() and .unwrap() in this project. This causes panic, // which will affect stability. -use std::sync::Mutex; +use std::sync::Mutex; +use std::thread; /// Variable which show current runlevel; -pub static mut RUNLEVEL_STATE: Mutex = Mutex::new(Runlevel::Undefined); +pub static RUNLEVEL_STATE: Mutex = Mutex::new(Runlevel::Undefined); +// TODO: Add proper RUNLEVEL_STATE switching fn main() -> Result<(), Box> { println!("Initializing your system."); if let Err(e) = check_pid() { @@ -77,5 +79,7 @@ fn main() -> Result<(), Box> { let _ = sigchld::setup_sigchld_handler(); + thread::spawn(move || services_mainloop()); + Ok(()) } -- cgit v1.2.3