This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] PR 31228, Fix close-on-exec race.


Tom Tromey wrote:
"David" == David Daney <ddaney@avtrex.com> writes:

David> Make the accept non-blocking, and do a select/poll on the David> ServerSocket. That way the accept would never block and you could use David> a mutex.

Yeah. I hadn't thought of the accept case, thanks.

David> This makes me think that ld.so is probably broken also.  When we do
David> dlopen ld.so opens the library file and does several mmaps before
David> closing the file descriptor.  These could leak out as well.

Not to mention other places that libc may create fds.

On some platforms fdwalk(3) can be used to make this close loop more
efficient.  There's also closefrom(3).  Linux doesn't seem to have
either of these, but Solaris does.

Tom

It would be fairly simple to write a linux version of closefrom(3) by reading /proc/self/fd. I think that may be the best choice.


David Daney.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]