- if (!min) {
- fl = fcntl(f->fd, F_GETFL);
- fcntl(f->fd, F_SETFL, fl | O_NONBLOCK);
+ pfds = malloc(sizeof(struct pollfd) * td->nr_files);
+ fl = malloc(sizeof(int) * td->nr_files);
+
+ for_each_file(td, f, i) {
+ /*
+ * don't block for min events == 0
+ */
+ if (!min) {
+ fl[i] = fcntl(f->fd, F_GETFL);
+ fcntl(f->fd, F_SETFL, fl[i] | O_NONBLOCK);
+ }
+ pfds[i].fd = f->fd;
+ pfds[i].events = POLLIN;