- if (!epoll_ctl (epoll_fd, mode, fd, &ev))
- fd_kill (EV_A_ fd);
+ if (expect_false (epoll_ctl (backend_fd, mode, fd, &ev)))
+ if (errno != ENOENT /* on ENOENT the fd went away, so try to do the right thing */
+ || (nev && epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev)))
+ fd_kill (EV_A_ fd);