watchdog: wait for WDT reset only if watchdogd is running

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-19 14:41:48 +02:00
parent 79dc6e7472
commit c85551a42e
2 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -267,7 +267,7 @@ void do_shutdown(shutop_t op)
/* Reboot via watchdog or kernel, or shutdown? */
if (op == SHUT_REBOOT) {
if (wdog) {
if (wdog && wdog->pid > 1) {
int timeout = 10;
/* Wait here until the WDT reboots, or timeout with fallback */
+4 -5
View File
@@ -93,7 +93,8 @@ static int loop(int fd, int timeout)
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
if (write(fd, "V", 1) == -1)
return EX_IOERR;
}
} else
syslog(LOG_ALERT, "System going down ...");
return EX_OK;
}
@@ -111,12 +112,10 @@ int main(int argc, char *argv[])
rc = loop(fd, WDT_TIMEOUT);
while (!handover) {
syslog(LOG_ALERT, "System going down ...");
/* Waiting for SIGTERM ... */
/* Waiting for SIGTERM or WDT reset ... */
sleep(1);
/* Set lowest possible timeout on SIGTERM */
/* Set lowest possible timeout on SIGPWR */
ioctl(fd, WDIOC_SETTIMEOUT, &shutdown);
}
close(fd);