summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-12-14 22:12:45 +0100
committerJohn Crispin <blogic@openwrt.org>2014-12-14 22:28:55 +0100
commit61cfe0d093056b85a311f06d44ac149e5dbb4d1a (patch)
tree74e598edf06f0e3dfc6380775ee5ea1e6ecd7105
parent40c4e68266a7b04239394c528c4c290d960fc38c (diff)
downloadunitd-61cfe0d093056b85a311f06d44ac149e5dbb4d1a.tar
unitd-61cfe0d093056b85a311f06d44ac149e5dbb4d1a.zip
only write to the watchdog if the fd is valid
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r--watchdog.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/watchdog.c b/watchdog.c
index 3c097e2..592ae7e 100644
--- a/watchdog.c
+++ b/watchdog.c
@@ -35,7 +35,7 @@ static int wdt_frequency = 5;
void watchdog_ping(void)
{
DEBUG(4, "Ping\n");
- if (write(wdt_fd, "X", 1) < 0)
+ if (wdt_fd >= 0 && write(wdt_fd, "X", 1) < 0)
ERROR("WDT failed to write: %s\n", strerror(errno));
}