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