This is the mail archive of the
mailing list for the glibc project.
Re: BZ#15722: create all sockets with SOCK_CLOEXEC
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: Alexandre Oliva <aoliva at redhat dot com>, libc-alpha at sourceware dot org
- Date: Thu, 11 Dec 2014 21:39:34 +0100
- Subject: Re: BZ#15722: create all sockets with SOCK_CLOEXEC
- Authentication-results: sourceware.org; auth=none
- References: <oregt6ahn2 dot fsf at free dot home> <20141113222048 dot A8CD02C3B18 at topped-with-meat dot com> <orzjbuy121 dot fsf at free dot home> <20141211192934 dot E9B892C3ACD at topped-with-meat dot com>
On Thu, Dec 11, 2014 at 11:29:34AM -0800, Roland McGrath wrote:
> This is a temporary fd used only within this function, never left open.
> If there is no underlying SOCK_CLOEXEC support, then calling fcntl after
> the fact is no more guarantee of anything than calling close in this
> function (and adds some overhead). My inclination is not to pretend to
> offer any race-free leaklessness if we cannot in fact offer it across
> the board.
> Perhaps we actually can require SOCK_CLOEXEC support nowadays, but we
> haven't ever explicitly said so before. (For Linux configurations,
> __ASSUME_SOCK_CLOEXEC is always set since we now support only kernels
> new enough. For the Hurd, *_CLOEXEC are actually implemented entirely
> in libc, though SOCK_CLOEXEC is not actually implemented yet. The other
> OS port forthcoming is NaCl, which does not have exec at all yet.)
At least it allows skip fcntl part entirely, linux is not problem and
for other systems should add both at same time, or we could handle
SOCK_CLOEXEC in wrapper by fcntl.