Q1 what happens if you add the same FD to an epoll_set twice?
A1 you will probably get eexist. However, it is possible that two threads may add the same FD twice. This is a harmless condition. (The same FD can be set twice)
Q2 can two epoll sets wait for the same FD? If so, are events reported to both epoll sets FDS?
A2 yes. However, it is not recommended. Yes it wocould be reported to both. (The same FD can be waited by two epoll sets)
Q3 is the epoll FD itself poll/epoll/selectable?
A3 yes. (epoll FD is the same as normal FD and can be set, meaning epoll_ctl is available)
Q4 what happens if the epoll FD is put into its own FD set?
A4 it will fail. However, you can add an epoll FD inside another epoll FD set.
Q5 can I send the epoll fd over a Unix-socket to another process?
A5 No. (This process can only be used)
Q6 will the close of an FD cause it to be removed from all epoll sets automatically?
A6 yes. (smart deletion)
Q7 if more than one event comes in between epoll_wait (2) CILS, are they combined or reported separately?
A7 they will be combined. (this should be noted, that is, both readable and writable)
Q8 does an operation on an FD affect the already collected but not yet reported events?
A8 you can do two operations on an existing FD. Remove wocould be meaningless for this case. Modify will re-read available I/O.
Q9 do I need to continuously read/write an FD until eagain when using the epollet flag (edge triggered behaviour )?
A9 no you don't. Locking ing an event from epoll_wait (2) shocould suggest to you that such file descriptor is ready for the requested I/O operation. You have simply to consider it ready until you will receive the next eagain. When and how you will use such file descriptor is entirely up to you. also, the condition that the read/write I/O space is exhausted (depletion) can be detected by checking the amount of data read/write from/to the target file descriptor. for example, if you call read (2) by asking to read a certain amount of data and read (2) returns a lower number of bytes, you can be sure to have exhausted the read I/O space for such file descriptor. same is valid when writing using the write (2) function. (that is, Detected Eagain is an insurance method, and the other method is that the number of bytes read is less than expected, it also indicates that the read cache is empty. )
Reference
[1] http://linux.die.net/man/4/epoll