Skip to contentSkip to conversation

epoll and shared fd's

DISCUSSION Bodo Eggert 4 participants 7 messages Feb 26, 2008 – Feb 28, 2008 7 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 27 lines · Michael Kerrisk

a) I did a

s/internal kernel handle/open file description/

since that is the POSIX term for the internal handle.

b) It seems to me that you text doesn't quite make the point explicit enough. I've tried to rewrite it; could you please check:

A6 Yes, but be aware of the following point. A file
descriptor is a reference to an open file descrip-
tion (see open(2)). Whenever a descriptor is
duplicated via dup(2), dup2(2), fcntl(2) F_DUPFD, or fork(2), a new file descriptor referring to the same open file description is created. An open file description continues to exist until all file descriptors referring to it have been closed. The
epoll interface automatically removes a file
descriptor from an epoll set only after all the file descriptors referring to the underlying open file handle have been closed. This means that even after a file descriptor that is part of an epoll set has been closed, events may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

Quoted 1 line

Does that seem okay? I plan to include the text in man-pages-2.79.

It's hard to read for me, and probably very hard to read for others.

#8 lore raw
Quoted 29 lines · Bodo Eggert
Quoted 27 lines · Michael Kerrisk

a) I did a

s/internal kernel handle/open file description/

since that is the POSIX term for the internal handle.

b) It seems to me that you text doesn't quite make the point explicit enough. I've tried to rewrite it; could you please check:

A6 Yes, but be aware of the following point. A file
descriptor is a reference to an open file descrip-
tion (see open(2)). Whenever a descriptor is
duplicated via dup(2), dup2(2), fcntl(2) F_DUPFD, or fork(2), a new file descriptor referring to the same open file description is created. An open file description continues to exist until all file descriptors referring to it have been closed. The
epoll interface automatically removes a file
descriptor from an epoll set only after all the file descriptors referring to the underlying open file handle have been closed. This means that even after a file descriptor that is part of an epoll set has been closed, events may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

Quoted 3 lines
Quoted 1 line

Does that seem okay? I plan to include the text in man-pages-2.79.

It's hard to read for me, and probably very hard to read for others.

Bodo,

I'm just reviewing this text, trying to see if I can improve it. At the moment, I'm a little stuck. can you say a little more about why you find it hard to read? that may help me improve it.

Cheers,

Michael

Signature · 5 lines
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug?  Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
#9 lore raw
Quoted 10 lines · Michael Kerrisk
Quoted 9 lines · Bodo Eggert
Quoted 7 lines · Michael Kerrisk

b) It seems to me that you text doesn't quite make the point explicit enough. I've tried to rewrite it; could you please check:

A6 Yes, but be aware of the following point. A file
descriptor is a reference to an open file descrip-
tion (see open(2)). Whenever a descriptor is
duplicated via dup(2), dup2(2), fcntl(2) F_DUPFD,

[.........]

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Does that seem okay? I plan to include the text in man-pages-2.79.

It's hard to read for me, and probably very hard to read for others.

Bodo,

I'm just reviewing this text, trying to see if I can improve it. At the moment, I'm a little stuck. can you say a little more about why you find it hard to read? that may help me improve it.

I think it's enough to mention that the last copy of the file descriptor (e.g. by dup or fork) must be closed *or* the file must be explicitely unregistered (As far as I understand by now).

Signature · 2 lines
"Aim towards the Enemy."
-Instruction printed on US Rocket Launcher
#10 lore raw
Quoted 20 lines · Bodo Eggert
Quoted 10 lines · Michael Kerrisk
Quoted 9 lines · Bodo Eggert
Quoted 7 lines · Michael Kerrisk

b) It seems to me that you text doesn't quite make the point explicit enough. I've tried to rewrite it; could you please check:

A6 Yes, but be aware of the following point. A file
descriptor is a reference to an open file descrip-
tion (see open(2)). Whenever a descriptor is
duplicated via dup(2), dup2(2), fcntl(2) F_DUPFD,

[.........]

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Does that seem okay? I plan to include the text in man-pages-2.79.

It's hard to read for me, and probably very hard to read for others.

Bodo,

Quoted 7 lines
Quoted 3 lines

I'm just reviewing this text, trying to see if I can improve it. At the moment, I'm a little stuck. can you say a little more about why you find it hard to read? that may help me improve it.

I think it's enough to mention that the last copy of the file descriptor (e.g. by dup or fork) must be closed *or* the file must be explicitely unregistered (As far as I understand by now).

Exactly!
Michael, I noticed that there's a reference to it in Q6. We better clarify that one.

- Davide

#11 lore raw
In reply to Bodo Eggert
Quoted 8 lines · Bodo Eggert
Quoted 6 lines · Michael Kerrisk

file handle have been closed. This means that even after a file descriptor that is part of an epoll set has been closed, events may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

Is it worth making special mention of the case where a process gets events for a FD that it has closed, because a parent or child process still has an inherited copy of the FD still open?

#12 lore raw
Quoted 11 lines · On Thu, Feb 28, 2008 at 2:53 PM, <[email protected]> wrote:
Quoted 9 lines · Bodo Eggert
Quoted 6 lines · Michael Kerrisk

file handle have been closed. This means that even after a file descriptor that is part of an epoll set has been closed, events may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

Quoted 3 lines

Is it worth making special mention of the case where a process gets events for a FD that it has closed, because a parent or child process still has an inherited copy of the FD still open?

I'm not sure -- perhaps under a BUGS section? Did you read my reply about this point in the thread "Re: epoll design problems with common fork/exec patterns"?

Cheers,

Michael

Signature · 5 lines
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug?  Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
#13 lore raw
In reply to [email protected]
Quoted 10 lines · On Thu, 28 Feb 2008, [email protected] wrote:
Quoted 8 lines · Bodo Eggert
Quoted 6 lines · Michael Kerrisk

file handle have been closed. This means that even after a file descriptor that is part of an epoll set has been closed, events may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

Quoted 3 lines

Is it worth making special mention of the case where a process gets events for a FD that it has closed, because a parent or child process still has an inherited copy of the FD still open?

And for all the others, there's epoll_ctl(EPOLL_CTL_DEL) :) The close(2) (f_op->release actually) hook is for cleanup semantics. If you play with multiple processes, just use epoll_ctl(EPOLL_CTL_DEL) and you'll be fine.

- Davide