Skip to content

Commit 21d41c1

Browse files
authored
Merge pull request #1472 from cgwalters/drop-another-task
reboot: Drop use of Task
2 parents 242f076 + 6770add commit 21d41c1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

crates/lib/src/reboot.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
//! Handling of system restarts/reboot
22
3-
use std::io::Write;
3+
use std::{io::Write, process::Command};
44

5+
use bootc_utils::CommandRunExt;
56
use fn_error_context::context;
67

7-
use crate::task::Task;
8-
98
/// Initiate a system reboot.
109
/// This function will only return in case of error.
1110
#[context("Initiating reboot")]
1211
pub(crate) fn reboot() -> anyhow::Result<()> {
1312
// Flush output streams
1413
let _ = std::io::stdout().flush();
1514
let _ = std::io::stderr().flush();
16-
Task::new("Rebooting system", "systemd-run")
15+
Command::new("systemd-run")
1716
.args([
1817
"--quiet",
1918
"--",
2019
"systemctl",
2120
"reboot",
2221
"--message=Initiated by bootc",
2322
])
24-
.run()?;
25-
tracing::debug!("Initiated reboot, sleeping forever...");
23+
.run_capture_stderr()?;
24+
// We expect to be terminated via SIGTERM here. We sleep
25+
// instead of exiting an exit would necessarily appear
26+
// racy to calling processes in that sometimes we'd
27+
// win the race to exit, other times might get killed
28+
// via SIGTERM.
29+
tracing::debug!("Initiated reboot, sleeping");
2630
loop {
2731
std::thread::park();
2832
}

0 commit comments

Comments
 (0)