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 <1299078834.78.0.76108876402.issue11284@psf.upfronthosting.co.za>
In-reply-to
Content
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.

Remarks:
- 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 ?
History
Date User Action Args
2011-03-02 15:13:54neologixsetrecipients: + neologix, loewis, gregory.p.smith, pitrou, vstinner, s7v7nislands
2011-03-02 15:13:54neologixsetmessageid: <1299078834.78.0.76108876402.issue11284@psf.upfronthosting.co.za>
2011-03-02 15:13:47neologixlinkissue11284 messages
2011-03-02 15:13:47neologixcreate