Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vUFcG-003OGM-25 for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Dec 2025 02:44:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vUFcF-009nkl-1W for pgsql-hackers@arkaria.postgresql.org; Sat, 13 Dec 2025 02:44:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vUFcF-009nkb-0X for pgsql-hackers@lists.postgresql.org; Sat, 13 Dec 2025 02:44:15 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vUFcE-000PG2-1s for pgsql-hackers@postgresql.org; Sat, 13 Dec 2025 02:44:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5BD2iBad1086089; Fri, 12 Dec 2025 21:44:11 -0500 From: Tom Lane To: Thomas Munro cc: Bryan Green , pgsql-hackers Subject: Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain In-reply-to: References: <7f6779d5-7a0e-44c5-a85f-b4ef265db766@gmail.com> <35f9236e-95d8-4f31-ac6b-ec54b7de4bac@gmail.com> <7412f694-7c57-41e5-ae37-71136070b0da@gmail.com> Comments: In-reply-to Thomas Munro message dated "Wed, 10 Dec 2025 10:03:07 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1086087.1765593851.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 12 Dec 2025 21:44:11 -0500 Message-ID: <1086088.1765593851@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro writes: > Hearing nothing, pushed. fairywren is unimpressed: ../pgsql/src/test/modules/test_cloexec/test_cloexec.c: In function 'run_pa= rent_tests': ../pgsql/src/test/modules/test_cloexec/test_cloexec.c:137:29: warning: unu= sed 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=3DTRUE, passing handle val= ues 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