cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl and sock_cloexec

From: Paul Albrecht <albrecht_at_glccom.com>
Date: Tue, 26 Apr 2011 10:42:21 -0500

On Tue, 2011-04-26 at 10:22 -0500, Ben Noordhuis wrote:
> On Tue, Apr 26, 2011 at 16:00, Paul Albrecht <albrecht_at_glccom.com> wrote:
> > Sockets are created with the socket system call, not the open system
> > call, so we're talking about setting the SOCK_CLOEXEC flag as the
> > default whenever a socket is created using the socket system call. This
> > will have to be configurable on linux because the flag isn't supported
> > before 2.6.27. Not sure about the availability of the flag on other
> > unices.
>
> The traditional approach is to set FD_CLOEXEC with fcntl(sockfd,
> F_SETFD, FD_CLOEXEC) but that doesn't seem to work any more with
> 2.6.32. Maybe just as well, the time between socket() and fcntl() is a
> race window.

Yes, I agree. That's why I'd prefer to set the flag when the socket is
created.

> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-- 
Paul Albrecht
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-04-26