pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Unportable implementation of background worker start
Date: Fri, 21 Apr 2017 14:08:21 -0400
Message-ID: <21444.1492798101@sss.pgh.pa.us> (raw)
In-Reply-To: <20625.1492796967@sss.pgh.pa.us>
References: <20170421151941.45njrtwykn5dd476@alvherre.pgsql>
	<18193.1492793404@sss.pgh.pa.us>
	<20170421172044.zcyslu7kcu7tfrsv@alap3.anarazel.de>
	<20625.1492796967@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

I wrote:
> Andres Freund <andres@anarazel.de> writes:
>> On 2017-04-21 12:50:04 -0400, Tom Lane wrote:
>>> +#ifndef FD_CLOEXEC
>>> +#define FD_CLOEXEC 1
>>> +#endif

>> Hm? Are we sure this is portable?  Is there really cases that have
>> F_SETFD, but not CLOEXEC?

> Copied-and-pasted from our only existing use of FD_CLOEXEC, in libpq.

Looking closer, that code dates to 

    Author: Tom Lane <tgl@sss.pgh.pa.us>
    Branch: master Release: REL8_0_BR [7627b91cd] 2004-10-21 20:23:19 +0000

    Set the close-on-exec flag for libpq's socket to the backend, to avoid
    any possible problems from child programs executed by the client app.
    Per suggestion from Elliot Lee of Red Hat.

and while the public discussion about it

https://www.postgresql.org/message-id/flat/18172.1098382248%40sss.pgh.pa.us

doesn't really say, I suspect the specific coding was Elliot's suggestion
as well.  It probably had some value at one time ... but I see that SUSv2
mandates that fcntl.h provide both F_SETFD and FD_CLOEXEC, so by our own
coding rules it ought to be okay to assume they're there.  I'm tempted to
rip out the quoted bit, as well as the #ifdef F_SETFD, from libpq and see
if anything in the buildfarm complains.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (52+ messages)  latest in thread

Message-ID: <21444.1492798101@sss.pgh.pa.us>
Permalink:  ../21444.1492798101@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21444.1492798101@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, alvherre@2ndquadrant.com
  Subject: Re: Unportable implementation of background worker start
  In-Reply-To: <21444.1492798101@sss.pgh.pa.us>
  References: <20170421151941.45njrtwykn5dd476@alvherre.pgsql> <18193.1492793404@sss.pgh.pa.us> <20170421172044.zcyslu7kcu7tfrsv@alap3.anarazel.de> <20625.1492796967@sss.pgh.pa.us> <21444.1492798101@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox