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.94.2) (envelope-from ) id 1sSO2A-006nd7-Vp for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 21:42:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sSO1A-00BxCI-Dc for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 21:41:28 +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.94.2) (envelope-from ) id 1sSO19-00BxC6-AZ for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2024 21:41:28 +0000 Received: from mail.clear-code.com ([2401:2500:102:3037:153:126:203:179]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSO15-001lAY-49 for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2024 21:41:25 +0000 Received: from localhost (unknown [IPv6:2404:7a80:89c1:1200:6af9:2266:1443:f149]) by mail.clear-code.com (Postfix) with ESMTPSA id BB9C8D1E48; Sat, 13 Jul 2024 06:41:16 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com BB9C8D1E48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1720820477; bh=9/b7rwLdRPAWB6+8Oy1mT5sZr9DRJ/bqVMgXycoveXA=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=L1uQl3rTagafkYW12UrXOSXeATh1ajyeEWh+JwfHvogNBlkjwA+WCMQd6nOBxc0vu 1pVApAVSQzvMBT0DeC7Cy6VyMfXgbKhReawOOTaLDtdXidXpsMIn55+lKmJmLd3dlr fdBF4DrkxGcHl5P61o4Bsf12ATj/SmEP++JrxpiA= Date: Sat, 13 Jul 2024 06:41:14 +0900 (JST) Message-Id: <20240713.064114.901257637518958249.kou@clear-code.com> To: michael@paquier.xyz Cc: robertmhaas@gmail.com, horikyota.ntt@gmail.com, kuroda.hayato@fujitsu.com, shlok.kyal.oss@gmail.com, pgsql-hackers@lists.postgresql.org, tgl@sss.pgh.pa.us Subject: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows From: Sutou Kouhei In-Reply-To: References: <20240111.173322.1809044112677090191.horikyota.ntt@gmail.com> X-Mailer: Mew version 6.8 on Emacs 29.4 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I'm reviewing patches in Commitfest 2024-07 from top to bottom: https://commitfest.postgresql.org/48/ This is the 2st patch: https://commitfest.postgresql.org/48/4573/ FYI: https://commitfest.postgresql.org/48/4681/ is my patch. In "Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows" on Tue, 4 Jun 2024 08:30:19 +0900, Michael Paquier wrote: > During a live review of this patch last week, as part of the Advanced > Patch Workshop of pgconf.dev, it has been mentioned by Tom that we may > be able to simplify the check on pmstart if the detection of the > postmaster PID started by pg_ctl is more stable using the WIN32 > internals that this patch relies on. I am not sure that this > suggestion is right, though, because we should still care about the > clock skew case as written in the surrounding comments? Even if > that's OK, I would assume that this should be an independent patch, > written on top of the proposed v6-0001. I reviewed the latest patch set and I felt different impression. start_postmaster() on Windows uses cmd.exe for redirection based on the comment in the function: > /* > * As with the Unix case, it's easiest to use the shell (CMD.EXE) to > * handle redirection etc. Unfortunately CMD.EXE lacks any equivalent of > * "exec", so we don't get to find out the postmaster's PID immediately. > */ It seems that we can use redirection by CreateProcess() family functions without cmd.exe based on the following documentation: https://learn.microsoft.com/en-us/windows/win32/procthread/creating-a-child-process-with-redirected-input-and-output How about changing start_postmaster() for Windows to start postgres.exe directly so that it returns the postgres.exe's PID not cmd.exe's PID? If we can do it, we don't need pgwin32_find_postmaster_pid() in the patch set. Thanks, -- kou