aboutsummaryrefslogtreecommitdiff
path: root/wd
diff options
context:
space:
mode:
authorWilly Tarreau <willy@wtap.(none)>2006-07-26 10:46:55 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 10:46:55 +0200
commitfcb250efba23ae522c4c8cb03c47dd40edcf9603 (patch)
tree3756bd1748842a3f1049d857e8412f148a8741b9 /wd
parentInitial commit (diff)
downloadflxutils-fcb250efba23ae522c4c8cb03c47dd40edcf9603.tar.xz
[RELEASE] flxutils-0.1.4.2v0.1.4.2
Diffstat (limited to 'wd')
-rw-r--r--wd/Makefile9
-rwxr-xr-xwd/wddbin0 -> 431 bytes
-rw-r--r--wd/wdd.c38
3 files changed, 47 insertions, 0 deletions
diff --git a/wd/Makefile b/wd/Makefile
new file mode 100644
index 0000000..a093caa
--- /dev/null
+++ b/wd/Makefile
@@ -0,0 +1,9 @@
+OBJS=wdd
+include ../include/rules.make
+CFLAGS+=-fomit-frame-pointer
+
+%: %.c
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
+ strip -R .comment -R .note $@
+ objdump -h $@ | grep -q '\.data[ ]*00000000' && strip -R .data $@ || true
+ sstrip $@
diff --git a/wd/wdd b/wd/wdd
new file mode 100755
index 0000000..15a911b
--- /dev/null
+++ b/wd/wdd
Binary files differ
diff --git a/wd/wdd.c b/wd/wdd.c
new file mode 100644
index 0000000..3ee0af8
--- /dev/null
+++ b/wd/wdd.c
@@ -0,0 +1,38 @@
+/*
+ * wdd - simple watchdog daemon - 2003 - willy tarreau
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+const char dev_wd_str[] = "/dev/watchdog";
+const char root_str[] = "/";
+
+int main (void) {
+ int dev;
+
+ if (fork() > 0)
+ return 0;
+ for (dev = 2; dev >= 0; dev--)
+ close(dev);
+ chdir(root_str);
+ setsid();
+ /* let's try indefinitely to open the watchdog device */
+ /* note that dev is -1 now ;-) */
+ while (1) {
+ if (dev == -1)
+ dev = open(dev_wd_str, O_RDWR);
+ if ((dev != -1) && (write(dev, dev_wd_str, 1) != 1)) {
+ /* write error, we'll restart */
+ close(dev);
+ dev = -1;
+ }
+ /* avoid a fast loop */
+ sleep(1);
+ }
+ /* we never get there theorically... */
+ return 0;
+}
+