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 09:00:49 -0500

On Mon, 2011-04-25 at 16:41 -0500, Daniel Stenberg wrote:
> On Mon, 25 Apr 2011, Ben Noordhuis wrote:
>
> > You're going to say "Well! Don't do that then!" and you'd be right. But this
> > is a kind of bug that easily slips through yet is very pernicious. To name
> > something: libcurl's connection cache. I've never tried it but I'm pretty
> > sure that forking while it's active is going to produce some rather
> > interesting and unexpected results.
> >
> > It's a good UNIX tradition to always open sockets and files with F_CLOEXEC -
> > or it used to be, anyway. But tradition or not, it's still a good idea. :-)
>
> I guess the question could perhaps also be put the other way: could there
> actually and realistically be any harm in making the sockets use F_CLOEXEC
> unconditionally?
>

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.

-- 
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