diff options
author | June McEnroe <june@causal.agency> | 2018-07-23 16:13:03 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-07-23 16:13:03 -0400 |
commit | 5649f07fff728086dce6e1cdd22cbcdb91582986 (patch) | |
tree | 9d40793b42a4f147f5d10bf430957ea0f47d49d7 | |
parent | Link with -lcurses (diff) | |
download | src-5649f07fff728086dce6e1cdd22cbcdb91582986.tar.gz src-5649f07fff728086dce6e1cdd22cbcdb91582986.zip |
Use EV_SET in watch
On NetBSD, kevent.udata is intptr_t rather than void *, and their EV_SET macro does the cast.
-rw-r--r-- | bin/watch.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/bin/watch.c b/bin/watch.c index 3308edc9..08a4ae9e 100644 --- a/bin/watch.c +++ b/bin/watch.c @@ -28,13 +28,16 @@ static void watch(int kq, char *path) { int fd = open(path, O_CLOEXEC); if (fd < 0) err(EX_NOINPUT, "%s", path); - struct kevent event = { - .ident = fd, - .filter = EVFILT_VNODE, - .flags = EV_ADD | EV_CLEAR, - .fflags = NOTE_WRITE | NOTE_DELETE, - .udata = path, - }; + struct kevent event; + EV_SET( + &event, + fd, + EVFILT_VNODE, + EV_ADD | EV_CLEAR, + NOTE_WRITE | NOTE_DELETE, + 0, + path + ); int nevents = kevent(kq, &event, 1, NULL, 0, NULL); if (nevents < 0) err(EX_OSERR, "kevent"); } @@ -86,7 +89,7 @@ int main(int argc, char *argv[]) { if (event.fflags & NOTE_DELETE) { close(event.ident); sleep(1); - watch(kq, event.udata); + watch(kq, (char *)event.udata); } exec(&argv[i]); |