This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, vstinner
Date 2018-06-05.11:29:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1528198179.8.0.592728768989.issue33773@psf.upfronthosting.co.za>
In-reply-to
Content
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@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@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.
History
Date User Action Args
2018-06-05 11:29:39vstinnersetrecipients: + vstinner, pitrou
2018-06-05 11:29:39vstinnersetmessageid: <1528198179.8.0.592728768989.issue33773@psf.upfronthosting.co.za>
2018-06-05 11:29:39vstinnerlinkissue33773 messages
2018-06-05 11:29:39vstinnercreate