mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
watchdog: wait for WDT reset only if watchdogd is running
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
79dc6e7472
commit
c85551a42e
2 files changed
+5
-6
No files matched your search
@@ -267,7 +267,7 @@ void do_shutdown(shutop_t op)
|
|||||||
|
|
||||||
/* Reboot via watchdog or kernel, or shutdown? */
|
/* Reboot via watchdog or kernel, or shutdown? */
|
||||||
if (op == SHUT_REBOOT) {
|
if (op == SHUT_REBOOT) {
|
||||||
if (wdog) {
|
if (wdog && wdog->pid > 1) {
|
||||||
int timeout = 10;
|
int timeout = 10;
|
||||||
|
|
||||||
/* Wait here until the WDT reboots, or timeout with fallback */
|
/* 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);
|
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
|
||||||
if (write(fd, "V", 1) == -1)
|
if (write(fd, "V", 1) == -1)
|
||||||
return EX_IOERR;
|
return EX_IOERR;
|
||||||
}
|
} else
|
||||||
|
syslog(LOG_ALERT, "System going down ...");
|
||||||
|
|
||||||
return EX_OK;
|
return EX_OK;
|
||||||
}
|
}
|
||||||
@@ -111,12 +112,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
rc = loop(fd, WDT_TIMEOUT);
|
rc = loop(fd, WDT_TIMEOUT);
|
||||||
while (!handover) {
|
while (!handover) {
|
||||||
syslog(LOG_ALERT, "System going down ...");
|
/* Waiting for SIGTERM or WDT reset ... */
|
||||||
|
|
||||||
/* Waiting for SIGTERM ... */
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Set lowest possible timeout on SIGTERM */
|
/* Set lowest possible timeout on SIGPWR */
|
||||||
ioctl(fd, WDIOC_SETTIMEOUT, &shutdown);
|
ioctl(fd, WDIOC_SETTIMEOUT, &shutdown);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|||||||
Reference in new issue
Block a user