#include #include #include #include #include #include #include #include #include #include #include #include #include #include void monitor_fds(); #define MIN_FD 0 #define SET_SZ 10 void die(const char *str) { perror(str); exit(EXIT_FAILURE); } int make_nonblocking(int fd) { int flags; if (-1 == (flags = fcntl(fd, F_GETFL))) return -1; flags |= O_NONBLOCK; if (-1 == fcntl(fd, F_SETFL, flags)) return -1; return 0; } void changeling() { pthread_t thread; int i = 7; if(pthread_create(&thread, NULL, monitor_fds, (void *)i)) { die("unable to start changeling thread\n"); } } struct timespec tmout = { 0, /* s */ 500000 /* ns */ }; void monitor_fds(){ sleep(5); printf("monitor_fds()...\n"); /* struct kevent changeList[SET_SZ]; struct kevent eventList[SET_SZ]; int sockfd, nev, kq; ssize_t nbytes; int error; char buf[BUFSIZ]; if (-1 == (kq = kqueue())) die("kqueue()"); for(int i=MIN_FD;i