In fact, you do not need to install event.data.fd . This is a union; you can establish other members. When epoll_wait returns, you get the event.data associated with the handle, which has become interesting:
typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t;
This means that you are completely free to not put anything in fd and instead put something in ptr (for example).
In conclusion, epoll_ctl cannot rely on the fact that you fill in fd , so it has a separate explicit parameter.
source share