#include #include #include #include #include #include #include #include #include #include #include #include #include #include void monitor_fds(); #define MIN_FD 0 #define MAX_FD_SCAN_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; printf("changeling()\n"); int i = 7; if(pthread_create(&thread, NULL, monitor_fds, (void *)i)) { die("unable to start changeling thread\n"); } } struct timespec tmout = { 0, /* block for 5 seconds at most */ 500000 }; /* nanoseconds */ void monitor_fds(){ //sleep(3); printf("monitor_fds()...\n"); struct kevent change[MAX_FD_SCAN_SZ], event[MAX_FD_SCAN_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 0) { if (nbytes != write(STDOUT_FILENO, buf, nbytes)) { die("write()"); } } } */ } } } }