projects
/
project
/
procd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
system: return legacy board name
[project/procd.git]
/
watchdog.c
diff --git
a/watchdog.c
b/watchdog.c
index
399f6af
..
780b321
100644
(file)
--- a/
watchdog.c
+++ b/
watchdog.c
@@
-32,11
+32,16
@@
static struct uloop_timeout wdt_timeout;
static int wdt_fd = -1;
static int wdt_frequency = 5;
static int wdt_fd = -1;
static int wdt_frequency = 5;
-
static void watchdog_timeout_cb(struct uloop_timeout *t
)
+
void watchdog_ping(void
)
{
DEBUG(4, "Ping\n");
{
DEBUG(4, "Ping\n");
- if (write(wdt_fd, "X", 1) < 0)
+ if (w
dt_fd >= 0 && w
rite(wdt_fd, "X", 1) < 0)
ERROR("WDT failed to write: %s\n", strerror(errno));
ERROR("WDT failed to write: %s\n", strerror(errno));
+}
+
+static void watchdog_timeout_cb(struct uloop_timeout *t)
+{
+ watchdog_ping();
uloop_timeout_set(t, wdt_frequency * 1000);
}
uloop_timeout_set(t, wdt_frequency * 1000);
}
@@
-121,10
+126,15
@@
void watchdog_init(int preinit)
}
}
-void watchdog_
no_cloexec(void
)
+void watchdog_
set_cloexec(bool val
)
{
if (wdt_fd < 0)
return;
{
if (wdt_fd < 0)
return;
- fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) & ~FD_CLOEXEC);
+ int flags = fcntl(wdt_fd, F_GETFD);
+ if (val)
+ flags |= FD_CLOEXEC;
+ else
+ flags &= ~FD_CLOEXEC;
+ fcntl(wdt_fd, F_SETFD, flags);
}
}