aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--svcsupervise.c26
2 files changed, 20 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index f96e4ca..87e986c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ svcscan: svcscan.c
${CC} ${CFLAGS} -o svcscan svcscan.c
svcsupervise: svcsupervise.c status.h
- ${CC} ${CFLAGS} -o svcsupervise svcsupervise.c
+ ${CC} ${CFLAGS} -DBROKEN_KQUEUE -o svcsupervise svcsupervise.c
svcok: svcok.c
${CC} ${CFLAGS} -o svcok svcok.c
diff --git a/svcsupervise.c b/svcsupervise.c
index e3b36fd..bffcb23 100644
--- a/svcsupervise.c
+++ b/svcsupervise.c
@@ -328,6 +328,18 @@ main(int argc, char **argv)
if ((ok_fd = open("supervise/ok", O_RDONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
err(1, "open()");
+#ifdef BROKEN_KQUEUE /* :( */
+ {
+ int ctrl_fd_w, ok_fd_w;
+
+ if ((ctrl_fd_w = open("supervise/control", O_WRONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
+ err(1, "open()");
+
+ if ((ok_fd_w = open("supervise/ok", O_WRONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
+ err(1, "open()");
+ }
+#endif
+
if (stat("./down", &sb) == -1) {
if (errno == ENOENT) {
wantup = 1;
@@ -337,13 +349,13 @@ main(int argc, char **argv)
wantup = 0;
}
- EV_SET(&evt[0], SIGHUP, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[1], SIGINT, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[2], SIGTERM, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[3], SIGCHLD, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[4], ctrl_fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[5], ok_fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0);
- EV_SET(&evt[6], 1, EVFILT_TIMER, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_SECONDS, 5, 0);
+ EV_SET(&evt[0], SIGHUP, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
+ EV_SET(&evt[1], SIGINT, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
+ EV_SET(&evt[2], SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
+ EV_SET(&evt[3], SIGCHLD, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
+ EV_SET(&evt[4], ctrl_fd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);
+ EV_SET(&evt[5], ok_fd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);
+ EV_SET(&evt[6], 1, EVFILT_TIMER, EV_ADD | EV_ONESHOT, NOTE_SECONDS, 5, 0);
if (kevent(kq, evt, 6, NULL, 0, NULL) == -1)
err(1, "kevent()");