for (i = 0; i < fd_count; i++) ufds[i].revents = 0;
drain_action_queue(); restart_processes();
if (process_needs_restart) { timeout = (process_needs_restart - gettime()) * 1000; if (timeout < 0) timeout = 0; }
nr = poll(ufds, fd_count, timeout); if (nr <= 0) continue;
if (ufds[2].revents == POLLIN) { /* we got a SIGCHLD - reap and restart as needed */ read(signal_recv_fd, tmp, sizeof(tmp)); while (!wait_for_one_process(0)) ; continue; }
if (ufds[0].revents == POLLIN) handle_device_fd(device_fd);
if (ufds[1].revents == POLLIN) handle_property_set_fd(property_set_fd); if (ufds[3].revents == POLLIN) handle_keychord(keychord_fd); }