Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyuDG-0003Yb-41 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 May 2023 12:55:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pyuDF-0004jx-24 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 May 2023 12:55:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pyuDE-0004jo-On for pgsql-hackers@lists.postgresql.org; Tue, 16 May 2023 12:55:32 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyuDB-0007ns-5v for pgsql-hackers@lists.postgresql.org; Tue, 16 May 2023 12:55:31 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 96EB620012; Tue, 16 May 2023 12:55:24 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------J660tPLM07hm0oBLEL7FDO4U" Message-ID: Date: Tue, 16 May 2023 08:55:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Content-Language: en-US To: Andres Freund Cc: Tom Lane , pgsql-hackers@lists.postgresql.org References: <5bddd941-9819-6655-7a71-3f346050583e@dunslane.net> <6efeb45a-07f9-2291-c8f8-9fb4abbb6ebc@dunslane.net> <20230427221828.2qo7z4xb4f7islln@awork3.anarazel.de> <236c0354-62b1-0ae1-a252-4c866bc1c5d6@dunslane.net> <20230504235413.eibaxlxslo76ipjl@awork3.anarazel.de> <2ff71af4-cdee-37b8-525a-2b25afd1769a@dunslane.net> <20230515193817.ttx4qf3ceqeufls2@awork3.anarazel.de> <26b0ebdb-3e7c-d562-620d-8e2f17286ff9@dunslane.net> <20230515201326.tbjgfdef6ul6oqfd@awork3.anarazel.de> <20230515223028.gkctmcoe7jtd5mmw@awork3.anarazel.de> <20230515234356.7ysq7w6jjsofeunt@awork3.anarazel.de> From: Andrew Dunstan Subject: Re: issue with meson builds on msys2 In-Reply-To: <20230515234356.7ysq7w6jjsofeunt@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------J660tPLM07hm0oBLEL7FDO4U Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2023-05-15 Mo 19:43, Andres Freund wrote: > Hi, > > On 2023-05-15 15:30:28 -0700, Andres Freund wrote: >> As soon as either the pg_ctl for the start, or the whole bash invocation, has >> stdin redirected, the problem vanishes. > For a moment I thought this could be related to InheritStdHandles() - but no, > it doesn't make a difference. > > There's loads of handles referencing cygwin alive in pg_ctl. > > Based on difference in strace output for bash -c "pg_ctl stop" for the case > where start redirected stdin (#1) and where not (#2), it looks like some part > of msys / cygwin sees that stdin is alive when preparing to execute "pg_ctl > stop", and then runs into trouble. > > The way we start the child process on windows makes the use of cmd.exe for > redirection pretty odd. > > > I couldn't trivially reproduce this with a much simpler case (just nohup > sleep). Perhaps it's dependent on a wrapper cmd or such. > > I don't know where this all leaves us. It's still more than odd that the start works fine and the stop doesn't. This piece of code has worked happily for years. It's only a recent installation or update of msys2 that's made the problem appear. I have implemented a workaround where IPC::Run is available - that means a little extra one-off work for people using msys2, but it's not a huge burden. Beyond that I don't really want to spend a lot more energy on it. I suppose the alternative would be to change the way the buildfarm calls pg_ctl stop. Do you have a concrete suggestion for that? cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------J660tPLM07hm0oBLEL7FDO4U Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2023-05-15 Mo 19:43, Andres Freund wrote:
Hi,

On 2023-05-15 15:30:28 -0700, Andres Freund wrote:
As soon as either the pg_ctl for the start, or the whole bash invocation, has
stdin redirected, the problem vanishes.
For a moment I thought this could be related to InheritStdHandles() - but no,
it doesn't make a difference.

There's loads of handles referencing cygwin alive in pg_ctl.

Based on difference in strace output for bash -c "pg_ctl stop" for the case
where start redirected stdin (#1) and where not (#2), it looks like some part
of msys / cygwin sees that stdin is alive when preparing to execute "pg_ctl
stop", and then runs into trouble.

The way we start the child process on windows makes the use of cmd.exe for
redirection pretty odd.


I couldn't trivially reproduce this with a much simpler case (just nohup
sleep). Perhaps it's dependent on a wrapper cmd or such.



I don't know where this all leaves us. It's still more than odd that the start works fine and the stop doesn't.

This piece of code has worked happily for years. It's only a recent installation or update of msys2 that's made the problem appear.

I have implemented a workaround where IPC::Run is available - that means a little extra one-off work for people using msys2, but it's not a huge burden. Beyond that I don't really want to spend a lot more energy on it.

I suppose the alternative would be to change the way the buildfarm calls pg_ctl stop. Do you have a concrete suggestion for that?


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------J660tPLM07hm0oBLEL7FDO4U--