[docs] [issue19444] mmap.mmap() allocates a file descriptor that isn't CLOEXEC
report at bugs.python.org
Wed Oct 30 10:45:36 CET 2013
Robert Merrill added the comment:
I'm adding Library again because I think the current behavior is a bug and should be fixed in the 2.7 tree. Perhaps the documentation in older versions should be updated
mmap.mmap should always set the FD_CLOEXEC flag on the descriptor that it gets from dup(). I don't see why we wouldn't do this, because if we are calling exec(), we are blowing away all python state, and only the mmap object should be using this file descriptor (since its existence is hidden from the user).
Users should not be depending on the old behavior, because the interface which is presented to them gives them no indication that this fd even exists. Users are probably expecting the proposed behavior, because anyone who has worked with unix file descriptors in C would not expect:
fd = os.open(...)
mmap = mmap.mmap(fd, size)
# do some stuff
To result in an extra inheritable fd still being there. Nothing in the documentation indicates that this would happen, either.
components: +Library (Lib)
versions: -Python 3.4
Python tracker <report at bugs.python.org>
More information about the docs