classification
Title: epoll docs are not clear with regards to CLOEXEC.
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, docs@python, python-dev, r.david.murray, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2013-12-31 15:58 by r.david.murray, last changed 2016-09-27 08:50 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
epoll.patch priyapappachan, 2014-03-25 11:55 EPOLL_CLOEXEC updated review
epoll.patch priyapappachan, 2014-03-25 14:03 review
epoll.patch priyapappachan, 2014-03-25 15:55 review
issue20100_v2.diff berker.peksag, 2016-09-08 20:31 review
selectmodule.diff berker.peksag, 2016-09-11 13:11 review
Messages (10)
msg207121 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-12-31 15:58
http://docs.python.org/dev/library/select.html#select.epoll documents the EPOLL_CLOEXEC flag as something you can specify that makes the file descriptor be closed on exec.  But then it goes on to say that the file descriptor is non-inheritable.  So is the flag useless and should be removed from the docs, or is the documentation just unclear as to its purpose?  Or, conversely, do we need a way to say that the file descriptor should *not* be closed on exec?
msg207124 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-12-31 16:19
Use os.set_inheritable(epoll.fileno(), True) to make the file descriptor
inheritable. You should find this info easily if you follow the link on
"non inheritable" in epoll documentation.

EPOLL_CLOEXEC becomes useless in Python 3.4. It is used internally by
default if available. Removing it would break existing code, it would be
harder to write code for python 3.4 and 3.3.

Just update the doc.
msg275141 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-08 20:31
Thanks for the patch, priyapappachan. Here is an updated patch. Since EPOLL_CLOEXEC is the only value that can be passed to epoll_create1(), we can also simplify the implementation a bit.
msg275783 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-11 12:45
New changeset 9023c4f5d467 by Berker Peksag in branch '3.5':
Issue #20100: Clarify that passing flags to epoll() has no effect
https://hg.python.org/cpython/rev/9023c4f5d467

New changeset d2b5806fa770 by Berker Peksag in branch 'default':
Issue #20100: Merge from 3.5
https://hg.python.org/cpython/rev/d2b5806fa770
msg275787 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-11 13:11
Here is an updated patch for Modules/selectmodule.c. It would be nice to get a code review.
msg275978 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-12 06:49
There is small behavior difference. Currently OSError raised for invalid flags has errno=EINVAL, with the patch it wouldn't have errno. If this is okay, the patch LGTM.
msg277466 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-26 20:28
New changeset ac24e5c2fd3e by Berker Peksag in branch 'default':
Issue #20100: Simplify newPyEpoll_Object()
https://hg.python.org/cpython/rev/ac24e5c2fd3e
msg277473 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-26 22:17
I dislike this change. Python is not responsible to check parameters of OS
syscalls, this function should be a thin wrapper to the OS function. Linux
may add new flags in the future.

Le lundi 26 septembre 2016, Roundup Robot <report@bugs.python.org> a écrit :

>
> Roundup Robot added the comment:
>
> New changeset ac24e5c2fd3e by Berker Peksag in branch 'default':
> Issue #20100: Simplify newPyEpoll_Object()
> https://hg.python.org/cpython/rev/ac24e5c2fd3e
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org <javascript:;>>
> <http://bugs.python.org/issue20100>
> _______________________________________
>
msg277505 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-27 08:25
Old code looked strange after issue18571:

        flags |= EPOLL_CLOEXEC;
        if (flags)
            self->epfd = epoll_create1(flags);
        else

The condition is always true unless EPOLL_CLOEXEC is 0.
msg277507 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-27 08:50
> Old code looked strange after issue18571:

epoll_create() is a deprecated. epoll_create(size): "Since Linux
2.6.8, the size argument is ignored, but must be  greater  than  zero"
according to the man page. So it's fine to always call
epoll_create1(flags).

Example of new potential new flag for epoll_create1(): ten years ago,
EPOLL_NONBLOCK was proposed:
https://lkml.org/lkml/2008/8/24/130
(but it seems like it doesn't make sense, since the syscall cannot block)

Recent epoll evolutions don't seem to be on epoll_create1():
https://lwn.net/Articles/633422/
History
Date User Action Args
2016-09-27 08:50:12vstinnersetmessages: + msg277507
2016-09-27 08:25:27serhiy.storchakasetmessages: + msg277505
2016-09-26 22:17:40vstinnersetmessages: + msg277473
2016-09-26 20:29:08berker.peksagsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-09-26 20:28:54python-devsetmessages: + msg277466
2016-09-12 06:49:44serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg275978
2016-09-11 13:11:35berker.peksagsetfiles: + selectmodule.diff

messages: + msg275787
2016-09-11 12:45:35python-devsetnosy: + python-dev
messages: + msg275783
2016-09-08 20:31:07berker.peksagsetfiles: + issue20100_v2.diff
versions: + Python 3.5, Python 3.6, Python 3.7, - Python 3.4
nosy: + berker.peksag

messages: + msg275141

stage: needs patch -> patch review
2014-03-25 15:55:00priyapappachansetfiles: + epoll.patch
2014-03-25 14:03:43priyapappachansetfiles: + epoll.patch
2014-03-25 11:55:02priyapappachansetfiles: + epoll.patch
keywords: + patch
2013-12-31 16:20:00vstinnersetmessages: + msg207124
2013-12-31 15:58:14r.david.murraycreate