Fix #54: Allow halt and poweroff despite --enable-watchdog

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-12-13 20:36:34 +01:00
1 parent a672988e35
commit 2c0421f2e6
1 file changed
+16 -13
+16 -13
View File
@@ -194,23 +194,26 @@ void do_shutdown(shutop_t op)
/* Call mdadm to mark any RAID array(s) as clean before halting. */ /* Call mdadm to mark any RAID array(s) as clean before halting. */
mdadm_wait(); mdadm_wait();
/* Wait here until the WDT reboots, or timeout */ /* Reboot via watchdog or kernel, or shutdown? */
if (wdogpid) { if (op == SHUT_REBOOT) {
int timeout = 10; if (wdogpid) {
int timeout = 10;
print(kill(wdogpid, SIGPWR) == 1, "Pending watchdog reboot"); /* Wait here until the WDT reboots, or timeout with fallback */
while (timeout--) print(kill(wdogpid, SIGPWR) == 1, "Pending watchdog reboot");
do_sleep(1); while (timeout--)
do_sleep(1);
}
_d("Rebooting ...");
reboot(RB_AUTOBOOT);
} else if (op == SHUT_OFF) {
_d("Powering down ...");
reboot(RB_POWER_OFF);
} }
_d("%s", op == SHUT_REBOOT ? "Rebooting" : "Halting");
if (op == SHUT_REBOOT)
reboot(RB_AUTOBOOT);
if (op == SHUT_OFF)
reboot(RB_POWER_OFF);
/* Also fallback if any of the other two fails */ /* Also fallback if any of the other two fails */
_d("Halting ...");
reboot(RB_HALT_SYSTEM); reboot(RB_HALT_SYSTEM);
} }