File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ;
56use 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" ) ]
1211pub ( 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 }
You can’t perform that action at this time.
0 commit comments