Re: File descriptors in exec'd subprocesses

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: File descriptors in exec'd subprocesses
Date: 2023-02-05 16:40:30
Message-ID: 20230205164030.5ptk6ch6ioin3tvr@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-02-05 11:06:13 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > On February 5, 2023 1:00:50 AM GMT+01:00, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> >> Are there any more descriptors we need to think about?
>
> > Postmaster's listen sockets?
>
> I wonder whether O_CLOEXEC on that would be inherited by the
> client-communication sockets, though.

I'd be very suprised if it were.

<hack>

Nope, at least not on linux. Verified by looking at /proc/*/fdinfo/n
after adding SOCK_CLOEXEC to just the socket() call. 'flags' changes
from 02 -> 02000002 for the listen socket, but stays at 04002 for the
client socket. If I add SOCK_CLOEXEC to accept() (well, accept4()), it
does change from 04002 to 02004002.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2023-02-05 17:05:51 Re: [PATCH] Compression dictionaries for JSONB
Previous Message Andres Freund 2023-02-05 16:08:38 Re: Weird failure with latches in curculio on v15