Lines 1-5
Link Here
|
1 |
/* $FreeBSD$ */ |
1 |
/* $FreeBSD$ */ |
2 |
|
2 |
|
|
|
3 |
#include <sys/event.h> |
3 |
#include <sys/poll.h> |
4 |
#include <sys/poll.h> |
4 |
#include <sys/socket.h> |
5 |
#include <sys/socket.h> |
5 |
#include <sys/stat.h> |
6 |
#include <sys/stat.h> |
Lines 202-207
child(int fd, int num)
Link Here
|
202 |
if ((res = poll(&pfd, 1, 0)) < 0) |
203 |
if ((res = poll(&pfd, 1, 0)) < 0) |
203 |
err(1, "poll"); |
204 |
err(1, "poll"); |
204 |
report(num++, "6b", POLLHUP, pfd.revents, res, 1); |
205 |
report(num++, "6b", POLLHUP, pfd.revents, res, 1); |
|
|
206 |
|
207 |
int kq = kqueue(); |
208 |
|
209 |
struct kevent kev; |
210 |
EV_SET(&kev, fd2, EVFILT_READ, EV_ADD, 0, 0, 0); |
211 |
if (kevent(kq, &kev, 1, NULL, 0, NULL) < 0) { |
212 |
err(1, "kevent"); |
213 |
} |
214 |
|
215 |
int n; |
216 |
struct timespec ts = { 0, 0 }; |
217 |
if ((n = kevent(kq, NULL, 0, &kev, 1, &ts)) < 0) { |
218 |
err(1, "kevent"); |
219 |
} |
220 |
for (int i = 0; i < n; ++i) { |
221 |
fprintf(stderr, "got event: %d\n", (int)kev.filter); |
222 |
fprintf(stderr, " fd: %d\n", (int)kev.ident); |
223 |
fprintf(stderr, " data: %d\n", (int)kev.data); |
224 |
fprintf(stderr, " flags: %x\n", (unsigned)kev.flags); |
225 |
fprintf(stderr, " fflags: %x\n", (unsigned)kev.fflags); |
226 |
} |
227 |
if (n == 0) { |
228 |
fprintf(stderr, "got no events\n"); |
229 |
} |
230 |
|
205 |
pfd.fd = fd; |
231 |
pfd.fd = fd; |
206 |
if ((res = poll(&pfd, 1, 0)) < 0) |
232 |
if ((res = poll(&pfd, 1, 0)) < 0) |
207 |
err(1, "poll"); |
233 |
err(1, "poll"); |