File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -698,18 +698,20 @@ int dinit_main(int argc, char **argv)
698
698
}
699
699
700
700
flush_log ();
701
+ bool need_log_flush = false ;
701
702
close_control_socket ();
702
703
703
704
if (am_system_mgr) {
704
705
if (shutdown_type == shutdown_type_t ::SOFTREBOOT) {
705
- sync (); // Sync to minimise data loss if user elects to power off / hard reset
706
+ sync (); // Sync to minimise data loss in case soft-boot fails
706
707
707
708
execv (dinit_exec, argv);
708
709
log (loglevel_t ::ERROR, error_exec_dinit, strerror (errno));
709
710
710
- // reboot if soft-reboot fails or memory allocation failed
711
+ // if we get here, soft reboot failed; reboot normally
711
712
log (loglevel_t ::ERROR, " Could not soft-reboot. Will attempt reboot." );
712
713
shutdown_type = shutdown_type_t ::REBOOT;
714
+ need_log_flush = true ;
713
715
}
714
716
715
717
if (shutdown_type == shutdown_type_t ::NONE) {
@@ -730,11 +732,17 @@ int dinit_main(int argc, char **argv)
730
732
catch (...) {
731
733
// Couldn't start boot service, let's reboot the system
732
734
log (loglevel_t ::ERROR, " Could not start 'boot' service. Will attempt reboot." );
735
+ need_log_flush = true ;
733
736
shutdown_type = shutdown_type_t ::REBOOT;
734
737
}
735
738
}
736
739
}
737
740
741
+ if (need_log_flush) {
742
+ // In case of error since the log was previously flushed, flush again now
743
+ flush_log ();
744
+ }
745
+
738
746
const char * cmd_arg;
739
747
if (shutdown_type == shutdown_type_t ::HALT) {
740
748
cmd_arg = " -h" ;
You can’t perform that action at this time.
0 commit comments