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 neologix
Recipients gregory.p.smith, loewis, neologix, pitrou, s7v7nislands, vstinner
Date 2011-03-02.15:13:47
SpamBayes Score 4.35484e-11
Marked as misclassified No
Message-id <>
Attached is a patch adding os.closefrom.
If closefrom(2) is available, it's used.
Otherwise, two options:
- if sysconf and _SC_OPEN_MAX are defined, we close each file descriptor up to _SC_OPEN_MAX
- if not, we choose a default value (256), and close every FD up to this value
subprocess has been converted to use it, and a test has been added in test_os
Unfortunately, I only have Linux boxes, so I can't really test it.

- is it OK to provide posix_closefrom even though the underlying platform doesn't support it ?
- no error code is returned (since when closing every FD manually this wouldn't make much sense), even though closefrom(2) does return one
- for the test, I only close FDs > 7 to avoid closing stdin/stdout/stder, but you might have a better idea
- this won't fix the problem for Linux, which doesn't have closefrom(2). Is it worth using /proc/self/fd interface ?
Date User Action Args
2011-03-02 15:13:54neologixsetrecipients: + neologix, loewis, gregory.p.smith, pitrou, vstinner, s7v7nislands
2011-03-02 15:13:54neologixsetmessageid: <>
2011-03-02 15:13:47neologixlinkissue11284 messages
2011-03-02 15:13:47neologixcreate