- fdcount = select(fd+1, &readfds, NULL, NULL, NULL);
- printf("select fd count: %i\n", fdcount);
-
- if (FD_ISSET(fd, &readfds)) {
- device = udev_monitor_receive_device(udev_monitor);
- if (device == NULL) {
- printf("no device from socket\n");
- continue;
+ fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), -1);
+ printf("epoll fd count: %i\n", fdcount);
+
+ for (i = 0; i < fdcount; i++) {
+ if (ev[i].data.fd == fd_udev && ev[i].events & EPOLLIN) {
+ device = udev_monitor_receive_device(udev_monitor);
+ if (device == NULL) {
+ printf("no device from socket\n");
+ continue;
+ }
+ print_device(device);
+ udev_device_unref(device);
+ } else if (ev[i].data.fd == STDIN_FILENO && ev[i].events & EPOLLIN) {
+ printf("exiting loop\n");
+ goto out;