From: John Crispin Date: Sun, 14 Dec 2014 21:12:45 +0000 (+0100) Subject: only write to the watchdog if the fd is valid X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=commitdiff_plain;h=61cfe0d093056b85a311f06d44ac149e5dbb4d1a only write to the watchdog if the fd is valid Signed-off-by: John Crispin --- 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)); }