File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
//! Handling of system restarts/reboot
2
2
3
- use std:: io:: Write ;
3
+ use std:: { io:: Write , process :: Command } ;
4
4
5
+ use bootc_utils:: CommandRunExt ;
5
6
use fn_error_context:: context;
6
7
7
- use crate :: task:: Task ;
8
-
9
8
/// Initiate a system reboot.
10
9
/// This function will only return in case of error.
11
10
#[ context( "Initiating reboot" ) ]
12
11
pub ( crate ) fn reboot ( ) -> anyhow:: Result < ( ) > {
13
12
// Flush output streams
14
13
let _ = std:: io:: stdout ( ) . flush ( ) ;
15
14
let _ = std:: io:: stderr ( ) . flush ( ) ;
16
- Task :: new ( "Rebooting system" , "systemd-run" )
15
+ Command :: new ( "systemd-run" )
17
16
. args ( [
18
17
"--quiet" ,
19
18
"--" ,
20
19
"systemctl" ,
21
20
"reboot" ,
22
21
"--message=Initiated by bootc" ,
23
22
] )
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" ) ;
26
30
loop {
27
31
std:: thread:: park ( ) ;
28
32
}
You can’t perform that action at this time.
0 commit comments