mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
watchdog: wait for WDT reset only if watchdogd is running
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user