Review request for 5049299
martinrb at google.com
Tue Jun 30 16:39:35 PDT 2009
I just filed glibc bug
Methods for deleting all file descriptors greater than given integer
In the JDK...
We close all non-relevant file descriptors in the child instead of relying
having the FD_CLOEXEC bit set properly for every fd in the parent.
The technique of choice appears to be to read /proc/self/fd and
close all the fds found therein.
That's even portable between linux and solaris!
On Tue, Jun 30, 2009 at 02:48, Michael McMahon <Michael.McMahon at sun.com>wrote:
> Roland McGrath wrote:
>> But...posix_spawn doesn't give you any way to delete *all* file
>>> and if you try to collect them before spawning, there is a race in a
>>> multithreaded program.
>> This is something you should never want to do. There is notoriously no
>> good way to do it on some systems, where getdtablesize() can return
>> RLIM_INFINITY and is not proper to use in a loop.
>> Use FD_CLOEXEC when you open the descriptor in the first place.
> We also need to chdir() before calling exec. And while some descriptors
> already have FD_CLOEXEC set, it's not easy to guarantee this for all of
> - Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the core-libs-dev