projects
/
project
/
procd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix a bug in the trigger handling code
[project/procd.git]
/
watchdog.c
diff --git
a/watchdog.c
b/watchdog.c
index
2a516b4
..
d927c53
100644
(file)
--- a/
watchdog.c
+++ b/
watchdog.c
@@
-91,24
+91,29
@@
char* watchdog_fd(void)
return fd_buf;
}
return fd_buf;
}
-void watchdog_init(
void
)
+void watchdog_init(
int preinit
)
{
char *env = getenv("WDTFD");
{
char *env = getenv("WDTFD");
+ if (wdt_fd >= 0)
+ return;
+
wdt_timeout.cb = watchdog_timeout_cb;
if (env) {
wdt_timeout.cb = watchdog_timeout_cb;
if (env) {
- LOG("- watchdog -\n");
DEBUG(1, "Watchdog handover: fd=%s\n", env);
wdt_fd = atoi(env);
DEBUG(1, "Watchdog handover: fd=%s\n", env);
wdt_fd = atoi(env);
- fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) | FD_CLOEXEC);
unsetenv("WDTFD");
} else {
wdt_fd = open("/dev/watchdog", O_WRONLY);
unsetenv("WDTFD");
} else {
wdt_fd = open("/dev/watchdog", O_WRONLY);
- if (getpid() != 1)
- fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) | FD_CLOEXEC);
}
}
+
if (wdt_fd < 0)
return;
if (wdt_fd < 0)
return;
+
+ if (!preinit)
+ fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) | FD_CLOEXEC);
+
+ LOG("- watchdog -\n");
watchdog_timeout(30);
watchdog_timeout_cb(&wdt_timeout);
watchdog_timeout(30);
watchdog_timeout_cb(&wdt_timeout);