epoll.7: Reformat Q&A list

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2018-06-22 09:27:24 +02:00
parent 4f4b395de2
commit 6832efaf3c
1 changed files with 20 additions and 40 deletions

View File

@ -326,24 +326,20 @@ calling
with with
.BR EPOLL_CTL_MOD . .BR EPOLL_CTL_MOD .
.SS Questions and answers .SS Questions and answers
.TP 4 .IP 0. 4
.B Q0
What is the key used to distinguish the file descriptors registered in an What is the key used to distinguish the file descriptors registered in an
.B epoll .B epoll
set? set?
.TP .IP
.B A0
The key is the combination of the file descriptor number and The key is the combination of the file descriptor number and
the open file description the open file description
(also known as an "open file handle", (also known as an "open file handle",
the kernel's internal representation of an open file). the kernel's internal representation of an open file).
.TP .IP 1.
.B Q1
What happens if you register the same file descriptor on an What happens if you register the same file descriptor on an
.B epoll .B epoll
instance twice? instance twice?
.TP .IP
.B A1
You will probably get You will probably get
.BR EEXIST . .BR EEXIST .
However, it is possible to add a duplicate However, it is possible to add a duplicate
@ -373,37 +369,31 @@ This can be a useful technique for filtering events,
if the duplicate file descriptors are registered with different if the duplicate file descriptors are registered with different
.I events .I events
masks. masks.
.TP .IP 2.
.B Q2
Can two Can two
.B epoll .B epoll
instances wait for the same file descriptor? instances wait for the same file descriptor?
If so, are events reported to both If so, are events reported to both
.B epoll .B epoll
file descriptors? file descriptors?
.TP .IP
.B A2
Yes, and events would be reported to both. Yes, and events would be reported to both.
However, careful programming may be needed to do this correctly. However, careful programming may be needed to do this correctly.
.TP .IP 3.
.B Q3
Is the Is the
.B epoll .B epoll
file descriptor itself poll/epoll/selectable? file descriptor itself poll/epoll/selectable?
.TP .IP
.B A3
Yes. Yes.
If an If an
.B epoll .B epoll
file descriptor has events waiting, then it will file descriptor has events waiting, then it will
indicate as being readable. indicate as being readable.
.TP .IP 4.
.B Q4
What happens if one attempts to put an What happens if one attempts to put an
.B epoll .B epoll
file descriptor into its own file descriptor set? file descriptor into its own file descriptor set?
.TP .IP
.B A4
The The
.BR epoll_ctl (2) .BR epoll_ctl (2)
call fails call fails
@ -413,24 +403,20 @@ However, you can add an
file descriptor inside another file descriptor inside another
.B epoll .B epoll
file descriptor set. file descriptor set.
.TP .IP 5.
.B Q5
Can I send an Can I send an
.B epoll .B epoll
file descriptor over a UNIX domain socket to another process? file descriptor over a UNIX domain socket to another process?
.TP .IP
.B A5
Yes, but it does not make sense to do this, since the receiving process Yes, but it does not make sense to do this, since the receiving process
would not have copies of the file descriptors in the would not have copies of the file descriptors in the
.B epoll .B epoll
set. set.
.TP .IP 6.
.B Q6
Will closing a file descriptor cause it to be removed from all Will closing a file descriptor cause it to be removed from all
.B epoll .B epoll
sets automatically? sets automatically?
.TP .IP
.B A6
Yes, but be aware of the following point. Yes, but be aware of the following point.
A file descriptor is a reference to an open file description (see A file descriptor is a reference to an open file description (see
.BR open (2)). .BR open (2)).
@ -457,34 +443,28 @@ This means that even after a file descriptor that is part of an
set has been closed, set has been closed,
events may be reported for that file descriptor if other file events may be reported for that file descriptor if other file
descriptors referring to the same underlying file description remain open. descriptors referring to the same underlying file description remain open.
.TP .IP 7.
.B Q7
If more than one event occurs between If more than one event occurs between
.BR epoll_wait (2) .BR epoll_wait (2)
calls, are they combined or reported separately? calls, are they combined or reported separately?
.TP .IP
.B A7
They will be combined. They will be combined.
.TP .IP 8.
.B Q8
Does an operation on a file descriptor affect the Does an operation on a file descriptor affect the
already collected but not yet reported events? already collected but not yet reported events?
.TP .IP
.B A8
You can do two operations on an existing file descriptor. You can do two operations on an existing file descriptor.
Remove would be meaningless for Remove would be meaningless for
this case. this case.
Modify will reread available I/O. Modify will reread available I/O.
.TP .IP 9.
.B Q9
Do I need to continuously read/write a file descriptor Do I need to continuously read/write a file descriptor
until until
.B EAGAIN .B EAGAIN
when using the when using the
.B EPOLLET .B EPOLLET
flag (edge-triggered behavior) ? flag (edge-triggered behavior) ?
.TP .IP
.B A9
Receiving an event from Receiving an event from
.BR epoll_wait (2) .BR epoll_wait (2)
should suggest to you that such should suggest to you that such