]>
git.saurik.com Git - apple/launchd.git/blob - launchd/testing/missed-EVFILT_READ.c
2 * <rdar://problem/4437060> EVFILT_READ doesn't fire reliably
8 #include <sys/socket.h>
16 static void do_parent(int thefd
);
17 static void do_child(int thefd
);
23 if (-1 == socketpair(AF_UNIX
, SOCK_STREAM
, 0, sp
)) {
24 fprintf(stderr
, "socketpair(): %s\n", strerror(errno
));
30 fprintf(stderr
, "fork(): %s\n", strerror(errno
));
51 if (-1 == write(thefd
, &junk
, sizeof(junk
))) {
52 fprintf(stderr
, "%d: write(): %s\n", __LINE__
, strerror(errno
));
55 if (-1 == read(thefd
, &junk
, sizeof(junk
))) {
56 fprintf(stderr
, "%d: read(): %s\n", __LINE__
, strerror(errno
));
65 struct timespec timeout
= { 5, 0 };
70 if (-1 == (kq
= kqueue())) {
71 fprintf(stderr
, "kqueue(): %s\n", strerror(errno
));
75 EV_SET(&kev
, thefd
, EVFILT_READ
, EV_ADD
, 0, 0, NULL
);
77 if (-1 == kevent(kq
, &kev
, 1, NULL
, 0, NULL
)) {
78 fprintf(stderr
, "%d: kevent(): %s\n", __LINE__
, strerror(errno
));
83 switch (kevent(kq
, NULL
, 0, &kev
, 1, &timeout
)) {
85 fprintf(stderr
, "%d: kevent(): %s\n", __LINE__
, strerror(errno
));
88 fprintf(stderr
, "After %d iterations, 4437060 still exists!\n", iter
);
93 fprintf(stderr
, "kevent should only return -1, 0 or 1 for this case!\n");
97 if (kev
.filter
!= EVFILT_READ
) {
98 fprintf(stderr
, "kevent should return EVFILT_READ!\n");
102 if (-1 == read(thefd
, &junk
, sizeof(junk
))) {
103 fprintf(stderr
, "read(): %s\n", strerror(errno
));
106 if (-1 == write(thefd
, &junk
, sizeof(junk
))) {
107 fprintf(stderr
, "%d: write(): %s\n", __LINE__
, strerror(errno
));