From 6770addebafc63392283b9dd92a5bf78cc227f62 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 31 Jul 2025 18:02:30 -0400 Subject: [PATCH] reboot: Drop use of Task It was not a useful abstraction in the end, just remove it. While here, also extend a comment with rationale for why we sleep. Signed-off-by: Colin Walters --- crates/lib/src/reboot.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/lib/src/reboot.rs b/crates/lib/src/reboot.rs index 420d06ede..63d7a5fe5 100644 --- a/crates/lib/src/reboot.rs +++ b/crates/lib/src/reboot.rs @@ -1,11 +1,10 @@ //! Handling of system restarts/reboot -use std::io::Write; +use std::{io::Write, process::Command}; +use bootc_utils::CommandRunExt; use fn_error_context::context; -use crate::task::Task; - /// Initiate a system reboot. /// This function will only return in case of error. #[context("Initiating reboot")] @@ -13,7 +12,7 @@ pub(crate) fn reboot() -> anyhow::Result<()> { // Flush output streams let _ = std::io::stdout().flush(); let _ = std::io::stderr().flush(); - Task::new("Rebooting system", "systemd-run") + Command::new("systemd-run") .args([ "--quiet", "--", @@ -21,8 +20,13 @@ pub(crate) fn reboot() -> anyhow::Result<()> { "reboot", "--message=Initiated by bootc", ]) - .run()?; - tracing::debug!("Initiated reboot, sleeping forever..."); + .run_capture_stderr()?; + // We expect to be terminated via SIGTERM here. We sleep + // instead of exiting an exit would necessarily appear + // racy to calling processes in that sometimes we'd + // win the race to exit, other times might get killed + // via SIGTERM. + tracing::debug!("Initiated reboot, sleeping"); loop { std::thread::park(); }