[issue20100] epoll docs are not clear with regards to CLOEXEC.
New submission from R. David Murray: 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? ---------- assignee: docs@python components: Documentation messages: 207121 nosy: docs@python, haypo, r.david.murray priority: normal severity: normal stage: needs patch status: open title: epoll docs are not clear with regards to CLOEXEC. type: behavior versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
STINNER Victor added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Changes by priya <priyapappachan010@gmail.com>: ---------- keywords: +patch Added file: http://bugs.python.org/file34611/epoll.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Changes by priya <priyapappachan010@gmail.com>: Added file: http://bugs.python.org/file34616/epoll.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Changes by priya <priyapappachan010@gmail.com>: Added file: http://bugs.python.org/file34618/epoll.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Berker Peksag added the comment: 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. ---------- nosy: +berker.peksag stage: needs patch -> patch review versions: +Python 3.5, Python 3.6, Python 3.7 -Python 3.4 Added file: http://bugs.python.org/file44476/issue20100_v2.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Berker Peksag added the comment: Here is an updated patch for Modules/selectmodule.c. It would be nice to get a code review. ---------- Added file: http://bugs.python.org/file44553/selectmodule.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Serhiy Storchaka added the comment: 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. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
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> <http://bugs.python.org/issue20100> _______________________________________
STINNER Victor added the comment: 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> _______________________________________
---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Changes by Berker Peksag <berker.peksag@gmail.com>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
Serhiy Storchaka added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
STINNER Victor added the comment:
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/ ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue20100> _______________________________________
participants (6)
-
Berker Peksag
-
priya
-
R. David Murray
-
Roundup Robot
-
Serhiy Storchaka
-
STINNER Victor