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
+8 -5
+8 -5
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 (op == SHUT_REBOOT) {
if (wdogpid) { if (wdogpid) {
int timeout = 10; int timeout = 10;
/* Wait here until the WDT reboots, or timeout with fallback */
print(kill(wdogpid, SIGPWR) == 1, "Pending watchdog reboot"); print(kill(wdogpid, SIGPWR) == 1, "Pending watchdog reboot");
while (timeout--) while (timeout--)
do_sleep(1); do_sleep(1);
} }
_d("%s", op == SHUT_REBOOT ? "Rebooting" : "Halting"); _d("Rebooting ...");
if (op == SHUT_REBOOT)
reboot(RB_AUTOBOOT); reboot(RB_AUTOBOOT);
} else if (op == SHUT_OFF) {
if (op == SHUT_OFF) _d("Powering down ...");
reboot(RB_POWER_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);
} }