[issue19444] mmap.mmap() allocates a file descriptor that isn't CLOEXEC

Robert Merrill 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
os.close(fd)

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>
<http://bugs.python.org/issue19444>
_______________________________________


More information about the Python-bugs-list mailing list