[New-bugs-announce] [issue33773] test.support.fd_count(): off-by-one error when listing /proc/self/fd/
STINNER Victor
report at bugs.python.org
Tue Jun 5 07:29:39 EDT 2018
New submission from STINNER Victor <vstinner at redhat.com>:
test.support.fd_count() has two implementation: list /proc/self/fd/ on Linux and FreeBSD, or check all file descriptors from 0 and MAXFD. The problem is that the two implementation don't give the same result...
List /proc/self/fd/ (used by default on Linux):
vstinner at apu$ ./python -c 'from test.support import fd_count; print(fd_count())'
4
Check all FD (I modified fd_count() to force using this implementation):
vstinner at apu$ ./python -c 'from test.support import fd_count; print(fd_count())'
3
On Linux and FreeBSD, listdir() opens internally a file descriptor to list the content of the /proc/self/fd/ directory. So the function should substract one to the result.
Attached PR fixes the issue.
----------
components: Tests
messages: 318734
nosy: pitrou, vstinner
priority: normal
severity: normal
status: open
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33773>
_______________________________________
More information about the New-bugs-announce
mailing list