Skip to contentSkip to conversation

No NONBLOCK flag for dup3() or epoll_create1()?

DISCUSSION Michael Kerrisk 3 participants 6 messages Aug 20, 2008 – Sep 2, 2008

lore
Share & tools
lore
#0 lore raw

Ulrich

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

all of the system calls should accept a *_NONBLOCK flag. All of them do, except for two:
dup3(olfd, newfd, flags)
and
epoll_create1(flags).

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

For dup3() it is perhaps also an oversight. However, it's not really clear to me whether supporting O_NONBLOCK makes sense, since that would change the file status flags of the open file description that is (also) referred to by oldfd. (Furthermore, given a open file description for which O_NONBLOCK is already enabled, it is not possible to make a dup3() call that disables O_NONBLOCK, which is an odd asymmetry in the API.) What are your thoughts on this?

Cheers,

Michael

#1 lore raw
Quoted 7 lines · Michael Kerrisk

Ulrich

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

Quoted 8 lines

all of the system calls should accept a *_NONBLOCK flag. All of them do, except for two:
dup3(olfd, newfd, flags)
and
epoll_create1(flags).

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

Traditionally the no-wait epoll_wait() has been achieved with a zero timeout, but _NONBLOCK support can be easily added if seen as necessary.

- Davide

#2 lore raw
In reply to Michael Kerrisk

Ping!

Quoted 30 lines · Michael Kerrisk

Ulrich

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

all of the system calls should accept a *_NONBLOCK flag. All of them do, except for two:
dup3(olfd, newfd, flags)
and
epoll_create1(flags).

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

For dup3() it is perhaps also an oversight. However, it's not really clear to me whether supporting O_NONBLOCK makes sense, since that would change the file status flags of the open file description that is (also) referred to by oldfd. (Furthermore, given a open file description for which O_NONBLOCK is already enabled, it is not possible to make a dup3() call that disables O_NONBLOCK, which is an odd asymmetry in the API.) What are your thoughts on
this?

Cheers,

Michael

Signature · 4 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
#3 lore raw
In reply to Michael Kerrisk
Quoted 6 lines · Michael Kerrisk

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

all of the system calls should accept a *_NONBLOCK flag.

This was never the intention.

Quoted 2 lines

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

I can. There is already a method to not block (zero timeout). We should not provide multiple ways to get the same functionality. It would require changes in the epoll code as well. That's not worth it.

Quoted 3 lines

(Furthermore, given a open file description for which O_NONBLOCK is
already enabled, it is not possible to make a dup3() call that disables O_NONBLOCK, which is an odd asymmetry in the API.)

That's why I didn't add support for the flag. It's hardly useful to add this support.

#4 lore raw
Quoted 10 lines · Ulrich Drepper
Quoted 6 lines · Michael Kerrisk

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

all of the system calls should accept a *_NONBLOCK flag.

This was never the intention.

All of the below makes some sense, but is at odds with what you posted on your blog entry, which documents *_NONBLOCK for both epoll_create1() and dup3(). Thus, I needed to check with you since the "intention" stated in the blog post differs from the actual implementation.

Quoted 5 lines
Quoted 2 lines

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

I can. There is already a method to not block (zero timeout). We should not provide multiple ways to get the same functionality.

Though, one reason to do so would be consistency with the other changed APIs. (There are many cases where *ix API provides more than one way of getting the same functionality.)

Quoted 10 lines

It
would require changes in the epoll code as well. That's not worth it.

Quoted 3 lines

(Furthermore, given a open file description for which O_NONBLOCK is
already enabled, it is not possible to make a dup3() call that disables O_NONBLOCK, which is an odd asymmetry in the API.)

That's why I didn't add support for the flag. It's hardly useful to add this support.

Cheers,

Michael

Signature · 4 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
#5 lore raw
In reply to Ulrich Drepper
Quoted 10 lines · Ulrich Drepper
Quoted 6 lines · Michael Kerrisk

I've been doing some testing (2.6.27-rc3) of your new file-descriptor-creating syscalls that accept flags. According to

http://udrepper.livejournal.com/20407.html

all of the system calls should accept a *_NONBLOCK flag.

This was never the intention.

All of the below makes some sense, but is at odds with what you posted on your blog entry, which documents *_NONBLOCK for both epoll_create1() and dup3(). Thus, I needed to check with you since the "intention" stated in the blog post differs from the actual implementation.

Quoted 5 lines
Quoted 2 lines

For epoll_create1() this certainly appears to be an oversight, since I can't think of a reason not to support *_NONBLOCK.

I can. There is already a method to not block (zero timeout). We should not provide multiple ways to get the same functionality.

Though, one reason to do so would be consistency with the other changed APIs. (There are many cases where *ix API provides more than one way of getting the same functionality.)

Quoted 10 lines

It
would require changes in the epoll code as well. That's not worth it.

Quoted 3 lines

(Furthermore, given a open file description for which O_NONBLOCK is
already enabled, it is not possible to make a dup3() call that disables O_NONBLOCK, which is an odd asymmetry in the API.)

That's why I didn't add support for the flag. It's hardly useful to add this support.

Cheers,

Michael

Signature · 4 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html