Sargun Dhillon <sargun@xxxxxxxxx> wrote: > On Sun, Oct 31, 2021 at 07:39:23AM +0000, Eric Wong wrote: > > CRIU? Checkpoint/Restore In Userspace? > > Sargun Dhillon <sargun@xxxxxxxxx> wrote: > > > Right, in CRIU, epoll is restored by manually cloning the FDs to the > right spot, and re-installing the events into epoll. This requires: > 0. Getting the original epoll FD > 1. Fetching / recreating the original FD > 2. dup2'ing it to right spot (and avoiding overwriting the original epoll FD) > 3. EPOLL_CTL_ADD'ing the FD back in. OK, am I understanding it's something like: int tmp_fd = epoll_create1(...); if (tmp_fd != orig_epfd) { dup2(tmp_fd, orig_epfd); close(tmp_fd); } for (/* loop over original FDs: */) { tmp_fd = socket(...); if (tmpfd != orig_sfd) { dup2(tmp_fd, orig_sfd); close(tmp_fd); } epoll_ctl(orig_epfd, EPOLL_CTL_ADD, orig_sfd, ...); } Is that close to what CRIU is doing? In no place does tmp_fd end up in the epoll rbtree, there. Everything is keyed w/ orig_sfd and it's underlying file.