Change to using the reboot and poweroff command
This commit is contained in:
parent
54c23fc67b
commit
69f24c63bd
@ -24,19 +24,25 @@ static bool power_screen_dispatch(PowerScreen *screen,
|
||||
if (state->sel_down) {
|
||||
switch (screen->choice) {
|
||||
case POWER_SCREEN_RESTART_PROGRAM:
|
||||
request_restart();
|
||||
request_exit(true);
|
||||
break;
|
||||
case POWER_SCREEN_REBOOT:
|
||||
LOG_VERBOSE("Rebooting...");
|
||||
if (system("reboot") != 0) {
|
||||
warnx("reboot(8) failed");
|
||||
// just force it if doing it cleanly failed
|
||||
reboot(RB_AUTOBOOT);
|
||||
abort();
|
||||
// how did we even get here???
|
||||
}
|
||||
request_exit(false);
|
||||
break;
|
||||
case POWER_SCREEN_POWEROFF:
|
||||
LOG_VERBOSE("Powering off...");
|
||||
if (system("poweroff") != 0) {
|
||||
warnx("poweroff(8) failed");
|
||||
// just force it if doing it cleanly failed
|
||||
reboot(RB_POWEROFF);
|
||||
abort();
|
||||
// how did we even get here???
|
||||
}
|
||||
request_exit(false);
|
||||
break;
|
||||
default:
|
||||
warnx("invalid power screen choice");
|
||||
@ -44,6 +50,7 @@ static bool power_screen_dispatch(PowerScreen *screen,
|
||||
LCD_DISPLAY_ON);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
screen->choice = (screen->choice + state->up_down - state->down_down) %
|
||||
POWER_SCREEN_NCHOICE;
|
||||
|
@ -476,7 +476,7 @@ static bool set_tz_screen_finish(SetTZScreen *screen,
|
||||
LOG_VERBOSE("Set timezone to: \"%s\"\n", buf);
|
||||
}
|
||||
free(buf);
|
||||
request_restart();
|
||||
request_exit(true);
|
||||
}
|
||||
if (state->up_down || state->back_down ||
|
||||
state->sel_down || state->down_down) {
|
||||
|
@ -535,9 +535,9 @@ bool mkdirs(const char *path, mode_t mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void request_restart() {
|
||||
void request_exit(bool restart) {
|
||||
RUNNING = false;
|
||||
SHOULD_RESTART = true;
|
||||
SHOULD_RESTART = restart;
|
||||
}
|
||||
|
||||
bool timed_wait(pid_t pid, int *out_status, useconds_t micro) {
|
||||
|
@ -251,10 +251,11 @@ bool export_database_as_csv(sqlite3 *db, const char *dest);
|
||||
bool mkdirs(const char *path, mode_t mode);
|
||||
|
||||
/*
|
||||
* Request that this program re-invoke itself with the same arguments. Used to
|
||||
* re-initialize configuration values.
|
||||
* Request that this program exit. If RESTART request instead that it re-invoke
|
||||
* itself with the same arguments.
|
||||
*/
|
||||
void request_restart(void);
|
||||
void request_exit(bool restart);
|
||||
|
||||
/*
|
||||
* waitpid(2) for PID for MICRO microseconds. If STATUS is not NULL, store the
|
||||
* exit status there. Use the various WIF* macros to test the status. This
|
||||
|
Loading…
Reference in New Issue
Block a user