Review request for 5049299
Martin Buchholz
martinrb at google.com
Tue Jun 30 23:39:35 UTC 2009
[+libc-alpha]
I just filed glibc bug
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10353
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
on
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!
Martin
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
>>> descriptors
>>> 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
> them.
>
> - Michael.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20090630/41ee68ab/attachment.html>
More information about the core-libs-dev
mailing list