diff --git a/src/sig.c b/src/sig.c index 603ff402..90ff1936 100644 --- a/src/sig.c +++ b/src/sig.c @@ -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 */ diff --git a/src/watchdog.c b/src/watchdog.c index f02b8ed8..761c72ba 100644 --- a/src/watchdog.c +++ b/src/watchdog.c @@ -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);