pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Bryan Green <dbryan.green@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain
Date: Fri, 12 Dec 2025 21:44:11 -0500
Message-ID: <1086088.1765593851@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKGKbWCzBPYGKuoTG2_8uCvrKuoHkvpbjxLUYhPDiJHapNg@mail.gmail.com>
References: <e2b16375-7430-4053-bda3-5d2194ff1880@gmail.com>
	<CA+hUKGJS=xdaQ6iCTSgvBrf8Cm+a_ZMmDjZYhdQX_srHkhOuqA@mail.gmail.com>
	<7f6779d5-7a0e-44c5-a85f-b4ef265db766@gmail.com>
	<35f9236e-95d8-4f31-ac6b-ec54b7de4bac@gmail.com>
	<7412f694-7c57-41e5-ae37-71136070b0da@gmail.com>
	<CA+hUKGLX7t_PZjcUGm2-hL52RsKwof4F+-ENN5qc0AOBMPY1_g@mail.gmail.com>
	<ac7fe47b-0079-4711-9c58-73467b1d262a@gmail.com>
	<e3b982d0-c56e-441e-a5d5-61de571e313c@gmail.com>
	<CA+hUKGJh0a_6EP8NLh6jjQjzzg=Nm_h9HMC19-tBww7ZqQDWVg@mail.gmail.com>
	<CA+hUKGKbWCzBPYGKuoTG2_8uCvrKuoHkvpbjxLUYhPDiJHapNg@mail.gmail.com>

Thomas Munro <thomas.munro@gmail.com> writes:
> Hearing nothing, pushed.

fairywren is unimpressed:

../pgsql/src/test/modules/test_cloexec/test_cloexec.c: In function 'run_parent_tests':
../pgsql/src/test/modules/test_cloexec/test_cloexec.c:137:29: warning: unused variable 'space_pos' [-Wunused-variable]
  137 |                 char       *space_pos;
      |                             ^~~~~~~~~

It's right, but it seems to me that this stanza needs more help than
that:

    /*
     * Spawn child process with bInheritHandles=TRUE, passing handle values as
     * hex strings
     */
    snprintf(cmdline, sizeof(cmdline), "\"%s\" %p %p",
             GetCommandLine(), h1, h2);

    /*
     * Find the actual executable path by removing any arguments from
     * GetCommandLine().
     */
    {
        char        exe_path[MAX_PATH];
        char       *space_pos;

        GetModuleFileName(NULL, exe_path, sizeof(exe_path));
        snprintf(cmdline, sizeof(cmdline), "\"%s\" %p %p",
                 exe_path, h1, h2);
    }

What is the point of that first snprintf(cmdline, ...), when its
result is guaranteed to be overwritten just below?

I'm also dubious about using MAX_PATH here; see the commentary
about MAXPGPATH in pg_config_manual.h.  Also, what's the point of
using MAX_PATH when the result is going to be transferred into
cmdline (with a hardwired size of 1024)?

			regards, tom lane





view thread (25+ messages)  latest in thread

Message-ID: <1086088.1765593851@sss.pgh.pa.us>
Permalink:  ../1086088.1765593851@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1086088.1765593851@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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, thomas.munro@gmail.com, dbryan.green@gmail.com
  Subject: Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain
  In-Reply-To: <1086088.1765593851@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