+
+/* Checks whether the given file descriptor caused the poll loop to wake up
+ * in the previous iteration. If it did, returns a bitmask of the events
+ * that caused the wakeup. Otherwise returns 0;
+ */
+short int
+poll_fd_woke(int fd)
+{
+ int i;
+ short int events = 0;
+
+ for (i = 0; i < n_pollfds; i++) {
+ if (pollfds[i].fd == fd) {
+ events |= pollfds[i].revents;
+ }
+ }
+
+ return events;
+}