From 61cfe0d093056b85a311f06d44ac149e5dbb4d1a Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 14 Dec 2014 22:12:45 +0100 Subject: only write to the watchdog if the fd is valid Signed-off-by: John Crispin --- watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)); } -- cgit v1.2.3