Rework Q1/A1, describing what happens when adding the same

file descriptor twice to an epoll set, and when adding duplicate
file descriptors to the same epoll set.
This commit is contained in:
Michael Kerrisk 2008-02-26 13:29:34 +00:00
parent f2e101d0ca
commit 2b22933411
1 changed files with 13 additions and 3 deletions

View File

@ -239,9 +239,19 @@ What happens if you add the same file descriptor to an epoll set twice?
.B A1
You will probably get
.BR EEXIST .
However, it is possible that two
threads may add the same file descriptor twice.
This is a harmless condition.
However, it is possible to add a duplicate
.RB ( dup (2),
.BR dup2 (2),
.BR fcntl (2)
.BR F_DUPFD ,
.BR fork (2))
descriptor to the same
.B epoll
set.
This can be a useful technique for filtering events,
if the duplicate file descriptors are registered with different
.I events
masks.
.TP
.B Q2
Can two