diff --git a/src/systemd.rs b/src/systemd.rs index 9d617d5..6ef02e4 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only +use std::path::Path; use std::process::{Command, Stdio}; use std::sync::OnceLock; @@ -33,21 +34,7 @@ pub fn stop_systemd_target() { ///Determine if systemd is used as the init system. This should work on all linux distributions. pub fn is_systemd_used() -> &'static bool { static IS_SYSTEMD_USED: OnceLock = OnceLock::new(); - IS_SYSTEMD_USED.get_or_init(|| { - match Command::new("ls").args(["/run/systemd/system"]).output() { - Ok(output) => { - if output.status.success() { - true - } else { - false - } - } - Err(error) => { - warn!("unable to check if systemd is used: {}", error); - false - } - } - }) + IS_SYSTEMD_USED.get_or_init(|| Path::new("/run/systemd/system").exists()) } #[cfg(feature = "systemd")]