()
| 9 | /// This function will only return in case of error. |
| 10 | #[context("Initiating reboot")] |
| 11 | pub(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 | } |
no test coverage detected