MCPcopy Create free account
hub / github.com/bootc-dev/bootc / reboot

Function reboot

crates/lib/src/reboot.rs:11–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9/// This function will only return in case of error.
10#[context("Initiating reboot")]
11pub(crate) fn reboot() -> anyhow::Result<()> {
12 // Flush output streams
13 let _ = std::io::stdout().flush();
14 let _ = std::io::stderr().flush();
15 Command::new("systemd-run")
16 .args([
17 "--quiet",
18 "--",
19 "systemctl",
20 "reboot",
21 "--message=Initiated by bootc",
22 ])
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");
30 loop {
31 std::thread::park();
32 }
33}

Callers 7

install_resetFunction · 0.70
upgradeFunction · 0.70
switch_ostreeFunction · 0.70
run_from_optFunction · 0.70
switch_composefsFunction · 0.50
apply_upgradeFunction · 0.50
upgrade_composefsFunction · 0.50

Calls 2

run_capture_stderrMethod · 0.80
argsMethod · 0.80

Tested by

no test coverage detected