forked from containers/bootc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: containers#165 Signed-off-by: Colin Walters <[email protected]>
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
pub mod cli; | ||
pub(crate) mod deploy; | ||
mod lsm; | ||
mod reboot; | ||
mod reexec; | ||
mod status; | ||
mod utils; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! Handling of system restarts/reboot | ||
use std::io::Write; | ||
use std::process::Command; | ||
|
||
use fn_error_context::context; | ||
|
||
/// Initiate a system reboot. | ||
/// This function will only return in case of error. | ||
#[context("Initiating reboot")] | ||
pub(crate) fn reboot() -> anyhow::Result<()> { | ||
// Flush output streams | ||
let _ = std::io::stdout().flush(); | ||
let _ = std::io::stderr().flush(); | ||
let st = Command::new("reboot").status()?; | ||
if !st.success() { | ||
anyhow::bail!("Failed to reboot: {st:?}"); | ||
} | ||
tracing::debug!("Initiated reboot, sleeping forever..."); | ||
loop { | ||
std::thread::park(); | ||
} | ||
} |